After creating a service and linking it to your application, you can use that service in any controller, directive, filter, or even within other services. To use the service inside a filter, include it as a dependency when defining the filter.
The hexafy service is utilized in the myFormat filter.
app.filter(‘myFormat’,[‘hexafy’, function(hexafy) { return function(x) { return hexafy.myFunc(x); }; }]); |
You can apply the filter when displaying values from either an object or an array.
<ul> <li ng-repeat=”x in counts”>{{x | myFormat}}</li> </ul> |