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

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