Skip to content

Instantly share code, notes, and snippets.

@morsdyce
Created May 29, 2013 14:45
Show Gist options
  • Save morsdyce/5670833 to your computer and use it in GitHub Desktop.
Save morsdyce/5670833 to your computer and use it in GitHub Desktop.
Multiple value angular filter #angularjs #filter
'use strict';
var app = angular.module('vulcanApp');
app.filter('byMultipleValues', function() {
return function(data, params) {
if (params.length === 0) {
return data;
}
return data.filter(function(element, index) {
for (var property in element) {
for (var i = 0, limit = params.length; i < limit; i++) {
if (element[property] === params[i]) {
return true;
}
}
}
return false;
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment