Reputation: 6944
I have two questions.
how to pass param to a filter function.
say for example:
item in masterData|filter1:masterdata|filter2:outputFromfilter1, myparam | filter3:outputFromfilter2, myparam1,myparam2
how to access the controller $scope
inside the filter function.
animateAppModule.filter( 'distinct' , function(){
return function(masterdata){
//HOW TO ACCESS THE $scope HERE
}
})
Here is a fiddle. Pls. look in to the firebug console, to see that the parameters passed to the filter is undefined
.
Upvotes: 10
Views: 13849
Reputation: 36030
You can give parameters separated by :
into the filter.
For example,
{{ array | myfilter:a:b:c }}
In your filter definition,
angular.module('app', []).
filter('myfilter', function() {
return function(in, param1, param2, param3) {
// do something
};
});
Not sure why you need to access $scope
.
Can you simply feed whatever needed information via param as your Q1?
Upvotes: 30