Tutorial by Examples

Filters format the value of an expression for display to the user. They can be used in view templates, controllers or services. This example creates a filter (addZ) then uses it in a view. All this filter does is add a capital 'Z' to the end of the string. example.js angular.module('main', []) ...
You will have to inject $filter: angular .module('filters', []) .filter('percentage', function($filter) { return function (input) { return $filter('number')(input * 100) + ' %'; }; });
By default, a filter has a single parameter: the variable it is applied on. But you can pass more parameter to the function: angular .module('app', []) .controller('MyController', function($scope) { $scope.example = 0.098152; }) .filter('percentage', function($filter) { return...

Page 1 of 1