Skip to content

Commit

Permalink
Add option for when arrayFilter is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
bignall committed Aug 21, 2016
1 parent 887f792 commit 4db4247
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/_filter/array/in-array.js
Expand Up @@ -6,14 +6,16 @@
* @description
* filter an array by a property in another array based on example http://jsbin.com/owIXEPE/2/edit?html,js,output
*/
angular.module('a8m.filter-by', [])
.filter('inArray', function($filter){
angular.module('a8m.in-array', [])
.filter('inArray', function($filter) {
return function(list, arrayFilter, element){
if(arrayFilter){
return $filter("filter")(list, function(listItem){
if (arrayFilter) {
return $filter("filter")(list, function(listItem) {
return arrayFilter.indexOf(listItem[element]) != -1;
});
} else {
return list;
}
};
}
});

0 comments on commit 4db4247

Please sign in to comment.