我有以下代码重复并显示用户名及其分数:<div ng-controller="AngularCtrl" ng-app> <div ng-repeat="user in users | orderBy:predicate:reverse | limitTo:10"> <div ng-init="user.score=user.id+1"> {{user.name}} and {{user.score}} </div> </div></div>以及相应的角度控制器。function AngularCtrl($scope) { $scope.predicate = 'score'; $scope.reverse = true; $scope.users = [{id: 1, name: 'John'}, {id: 2, name: 'Ken'}, {id: 3, name: 'smith'}, {id: 4, name: 'kevin'}, {id: 5, name: 'bob'}, {id: 6, name: 'Dev'}, {id: 7, name: 'Joe'}, {id: 8, name: 'kevin'}, {id: 9, name: 'John'}, {id: 10, name: 'Ken'}, {id: 11, name: 'John'}, {id: 1, name: 'John'}, {id: 2, name: 'Ken'}, {id: 3, name: 'smith'}, {id: 4, name: 'kevin'}, {id: 5, name: 'bob'}, {id: 6, name: 'Dev'}, {id: 7, name: 'Joe'}, {id: 8, name: 'kevin'}, {id: 9, name: 'John'}, {id: 10, name: 'Ken'}]}当我运行上面的代码时,我得到错误:10 $ digest()迭代达到。流产!我的控制台错误。我已经为它创建了jsfiddle。排序谓词仅在ng-repeat内部初始化,并且限制也应用于对象数。所以我觉得将sortby和limitTo监视程序放在一起是错误的原因。如果$ scope.reverse为false(分数的升序),则不会出错。谁能帮我了解这是怎么回事?非常感谢您的帮助。
添加回答
举报
0/150
提交
取消