Skip to content

Instantly share code, notes, and snippets.

@codearachnid
Created July 1, 2015 19:24
Show Gist options
  • Select an option

  • Save codearachnid/85a2ae67bd448a350834 to your computer and use it in GitHub Desktop.

Select an option

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
.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