December 2014
Intermediate to advanced
346 pages
6h 14m
English
Filters are built to perform template data processing, so their utilization outside the template will be infrequent. Nonetheless, AngularJS provides you with the ability to use filter functions via an injection of $filter.
Suppose that you have an application, as follows:
(app.js)
angular.module('myApp', [])
.controller('Ctrl', function ($scope) {
$scope.val = 1234.56789;
});In the view templates, the argument order is scrambled with the following format:
data | filter : optionalArgument
For this example, it would take the form in the template as follows:
<p>{{ val | number : 4 }}</p>This will give the following result:
1,234.5679
In this example, it's cleanest to apply the filter in the ...
Read now
Unlock full access