Reputation: 685
I have a custom filter with a $filter dependency:
app.filter('getRange',[ '$filter', function($filter) {
return function(data, data2) {
console.log(data); //this is empty
var result = $filter('3dparty_filter')(data,data2);
var another_var = $filter('another_filter')(result);
//do smth.
}
}]);
For some reason the arguments(data, data2) of the filter are empty. However, if I remove the $filter
dependency
app.filter('getRange',function() {
return function(data, data2) {
console.log(data); //this works, data is not empty.
// var result = $filter('3dparty_filter')(data,data2);
// var another_var = $filter('another_filter')(result);
//do smth.
}
});
everything works fine (i.e. data and data2 args are passed correctly). Could you please advise on how to properly inject $filter in my case or why the args are empty and how to fix that?
Upvotes: 1
Views: 1863
Reputation: 16498
Please see example here http://jsbin.com/ticoho/1/edit?html,js,console,output evrything is fine. Double check your html or there is a problem with 3rd part filters
app.filter('getRange',['$filter', function($filter) {
return function(data, data2) {
console.log(data);
console.log(data2);
return $filter('json')(data);
};
}]);
Upvotes: 2