AngularJS: API: ng/service/$filter


$filter

  1. - $filterProvider
  2. - service in module ng

Filters are used for formatting data displayed to the user.

The general syntax in templates is as follows:

    {{ expression [| filter_name[:parameter_value] ... ] }}

Usage

$filter(name);

Arguments

ParamTypeDetails
nameString

Name of the filter function to retrieve

Returns

Function

the filter function

Example

index.html
<div ng-controller="MainCtrl">
 <h3>{{ originalText }}</h3>
 <h3>{{ filteredText }}</h3></div>
script.js
angular.module('filterExample', []).controller('MainCtrl', function($scope, $filter) {
  $scope.originalText = 'hello';
  $scope.filteredText = $filter('uppercase')($scope.originalText);});