使用隨機orderBy
排序技術this question在AngularJS 1.1中正常工作。隨機orderBy in AngularJS 1.2返回'infdig'錯誤
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
沒有使用函數表達式的例子,只有字符串表達式。有沒有改變,或者這是一個錯誤?
更新:[錯誤提交](https://github.com/angular/angular.js/issues/6133#issuecomment-34229877)導致內部發生了什麼情況的解釋。 – Blazemonger