Created
July 1, 2015 19:24
-
-
Save codearachnid/85a2ae67bd448a350834 to your computer and use it in GitHub Desktop.
Needed a simple way to filter an array of object by a property
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
| .filter('filterByProperty', function(){ | |
| return function( items, propMatch ){ | |
| var filtered = []; | |
| for (var i = 0; i < items.length; i++) { | |
| var item = items[i]; | |
| for(var property in propMatch){ | |
| if (propMatch[property] == item[property]) { | |
| filtered.push(item); | |
| } | |
| } | |
| } | |
| return filtered; | |
| }; | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment