Angularjs Examples

AJS Examples

AngularJS $filter Service

The AngularJS $filter service is used for formatting data displayed to the user. The $filter service works with AngularJS built in filter like uppercase, lowercase, currency, orderby etc. It can be used with custom filter also.



AngularJS $filter Service Example

<!DOCTYPE html>  
<head> <!-- -->  
 <script src="//"></script>   
    <meta charset="utf-8">  
    <title>AngularJS $filter Example</title>  
var app = angular.module('app', []);  
    app.controller("FilterController", function ($scope,$filter) {  
      $ = '';
      $scope.salary = 0;
      $scope.UppercaseFilter = function()  
        $ = $filter('uppercase')($;  
      $scope.CurrencyFilter = function()  
         $scope.salary = $filter('currency')($scope.salary);       
<body style="background-color:#DDE4E9;">  
  <fieldset style="background-color:#DDE4E9;">              
    <legend>AngulerJS $filter Service Example</legend>   
  <div ng-app="app">        
    <div ng-controller="FilterController">   
      Enter Name (in small):          
        <input type="string" ng-model="name">          
        <button ng-click="UppercaseFilter()">Uppercase Filter</button></br>       
      Enter Salary:        
        <input type="string" ng-model="salary">          
        <button ng-click="CurrencyFilter()">Currency Filter</button> </br>       
See Live Example