Using the random orderBy
sort technique in this question works fine in 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();
}
}
In 1.2, though, it puts infdig
errors into the console and takes a much longer time to return the sorted results: http://jsfiddle.net/mblase75/jVs27/
The error in the console looks like:
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
doesn't have an example of using function expressions, only string expressions. Did something change, or is this a bug?