1

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?

1 Answer 1

2

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);

    };
}]);
Sign up to request clarification or add additional context in comments.

2 Comments

I'm sorry if I did not clarified it. I need to use $filter inside my custom filter. Unfortunately, your code is wrong as $filter is not injected therefore ReferenceError arises.
"Could you please advise on how to properly use $filter in my case?"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.