Created
April 1, 2015 14:35
-
-
Save fredyang/04cde5cfb4f4283e8ce2 to your computer and use it in GitHub Desktop.
angular filter to select on item froom array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '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