【发布时间】:2014-02-05 19:12:37
【问题描述】:
在this question 中使用随机的orderBy 排序技术在AngularJS 1.1 中可以正常工作。
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.list = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
$scope.random = function() {
return 0.5 - Math.random();
}
}
不过,在 1.2 中,它会将 infdig 错误放入控制台,并且需要更长的时间才能返回排序结果:http://jsfiddle.net/mblase75/jVs27/
控制台中的错误如下:
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [["fn: $watchCollectionWatch; newVal: 42; oldVal: 36"],["fn: $watchCollectionWatch; newVal: 47; oldVal: 42"],["fn: $watchCollectionWatch; newVal: 54; oldVal: 47"],["fn: $watchCollectionWatch; newVal: 61; oldVal: 54"],["fn: $watchCollectionWatch; newVal: 68; oldVal: 61"]]
The documentation for orderBy 没有使用函数表达式的示例,只有字符串表达式。有什么变化吗,或者这是一个错误?
【问题讨论】:
-
更新:error submission 解释了内部发生的事情。
标签: javascript angularjs angularjs-orderby