Using the random orderBy sort technique in this question works fine in AngularJS 1.1.
var myApp = angular.module(\'myApp\',[]);
function MyCtr
You can solve this in an Angular way with a simple custom filter. Here I'm using the underscore shuffle method which implements Fischer-Yates.
You could substitute the guts of the shuffle with your own algorithm if you prefer.
angular.module('shuffle', [])
.filter('shuffle', function() {
return function(ary) {
return _.shuffle(ary);
}
});
We can now pipe our array through this filter, like so:
-
The filter will be called once when the template is rendered.