Created
May 29, 2013 14:45
-
-
Save morsdyce/5670833 to your computer and use it in GitHub Desktop.
Multiple value angular filter #angularjs #filter
This file contains 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'; | |
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