Venkatesh S Venkatesh S - 2 months ago 8
AngularJS Question

how to use services function in filters (AngularJS)

I have a filter that returns values based on the ID. These values are dynamically fetched and stored in an array using SERVICES. Now I want to use this SERVICE function to fetch values dynamically and that will be used in the filter.

How can I call a service function in the filter?

Answer
app.filter('MyCustomFilter', ['ServiceHelper', function(ServiceHelper){
  return function(id) {
    ServiceHelper.get(id);
  }
}])