Use Array In Custom Filter
I created an array that has the following format... $scope.myArr = [arg1, arg2]; Now I want to create a custom filter that will take the array as a parameter and compare to anothe
Solution 1:
Your html with custom Angular#Filter should be
<div class="form-container" ng-repeat="formblock in forms | dateFilter:myArr">
Your forms
is passed as firsr parameter implicitely and passed the additional parameter with :
after filter name.
JS :
Filter :
app.filter('dateFilter', function() {
var boolFound = false;
returnfunction(arrForm, arrArg) {
arrForm.forEach(function(val, key) {
var boolFound = false;
arrArg.forEach(function(val1, key1) {
if (val.date === val1) {
boolFound = true;
}
});
if (boolFound === false) {
arrForm.splice(key, 1);
}
});
return arrForm;
}
})
Here is the updated Fiddle
Post a Comment for "Use Array In Custom Filter"