1
我有一个为restful api创建SubCon $资源的工厂。
app.factory("SubCon", function($resource) {
return $resource("http://localhost:8010/api/subcontractors/:id");
})
我有一个使用该服务的控制器,并直接将通过查询服务返回的承诺传递给ng-repeat。
//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();
}
而且模板:
<tr ng-repeat="partner in ctrl.getPartners()">
<td>{{partner.id}}</td>
<td>{{partner.name}}</td>
<td>?</td>
<td>?</td>
<td>---</td>
<td>?</td>
</tr>
现在,当我采用了棱角分明1.5.8运行此代码得到一个摘要错误,如下所示。
那么我错过了什么。为什么这与$ 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