How to inject a service as dependency for a custom filter in angular.js?
angularjs
Solution
Try:
app.filter('sageApp', ['segmentio', function(segmentio) {
return function(entry, category) {
segmentio.track(entry, category);
}
}]);
Problem
I am trying to create a custom filter to track events. So the filter can call methods on the segmentio service. ``` angular.module('sageApp') .filter('trackEvent', function(segmentio) { return function(entry, category) { segmentio.track(entry, category); } }); ``` But the segmentio service is not available. Any ideas on how to dependency inject a service to a filter woule be much appreciated.