Skip to content

Instantly share code, notes, and snippets.

@fredyang
Created April 1, 2015 14:35
Show Gist options
  • Select an option

  • Save fredyang/04cde5cfb4f4283e8ce2 to your computer and use it in GitHub Desktop.

Select an option

Save fredyang/04cde5cfb4f4283e8ce2 to your computer and use it in GitHub Desktop.
angular filter to select on item froom array
'use strict';
app.filter('random', function () {
function randomInt(min, max) {
return Math.round(Math.random() * (max - min) + min);
}
return function (items) {
var i = randomInt(0, items.length - 1);
return items ? items[i] : i;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment