Filters in Controllers and Services

We can also use filters in other components such as controllers and services. They can be used by just injecting $filter inside the desired components.

The first argument of the filter function is the value, followed by the other required arguments.

Let's change our application by moving the date filter, which we used to display the date and hour separated in the view, to our controller: controllers.js
payroll.controller("payrollCtrl", function ($scope, $filter) {
$scope.appTitle = $filter("uppercase")("www.rookienerd.com");
});

This approach is often used when we need to transform the data before it reaches the view, sometimes even using it to the algorithms logic.
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +