1
私は安らかなAPI用のSubCon $リソースを作成するファクトリを持っています。私は直接そのサービスを使用して、コントローラを持って
app.factory("SubCon", function($resource) {
return $resource("http://localhost:8010/api/subcontractors/:id");
})
はNGリピートにサービスを照会することによって返された約束を渡します。ここで
//in the controller
$scope.partners = this.SubCon.query();
は、テンプレート内の繰り返しである:
<tr ng-repeat="partner in partners">
<td>{{partner.id}}</td>
<td>{{partner.name}}</td>
<td>?</td>
<td>?</td>
<td>---</td>
<td>?</td>
</tr>
これは素晴らしい作品と私は期待するものを出力します。 私はこのようなコントローラとテンプレートリファクタリングので、だから我々は$スコープを使用して反対方針を持っている:
//in the controller
this.getPartners = function() {
return this.SubCon.query();
}
、テンプレート:私は角1.5.8を使用してこのコードを実行すると
<tr ng-repeat="partner in ctrl.getPartners()">
<td>{{partner.id}}</td>
<td>{{partner.name}}</td>
<td>?</td>
<td>?</td>
<td>---</td>
<td>?</td>
</tr>
を私は下記のダイジェストエラーが発生します。
私は何が欠けていますか。これは$ scopeで動作し、コントローラ上のメソッドを使用しないのはなぜですか?
angular.js:13920 Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.5.8/$rootScope/infdig?p0=10&p1=%5B%5D
at angular.js:68
at Scope.$digest (angular.js:17562)
at Scope.$apply (angular.js:17790)
at done (angular.js:11831)
at completeRequest (angular.js:12033)
at XMLHttpRequest.requestLoaded (angular.js:11966)(anonymous function) @ angular.js:13920
angular.js:17793 Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.5.8/$rootScope/infdig?p0=10&p1=%5B%5D