AngularJS_Basics6_Filters

<!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <body> <div ng-app="myApp" ng-controller="namesCtrl"> <p>The name is {{ lastName | uppercase }}</p> <p>The name is {{ lastName | lowercase }}</p> <p>Looping with objects:</p> <ul> <li ng-repeat="x in names | orderBy:'country' | filter : 'Gl'"> {{ x.name + ', ' + x.country }} </li> </ul> <h1>Price: {{ price | currency : "$" }}</h1> </div> <script> angular.module('myApp', []).controller('namesCtrl', function($scope) { $scope.firstName = "Priya", $scope.lastName = "Mounica", $scope.names = [ {name:'Jani',country:'Norway'}, {name:'Carl',country:'Sweden'}, {name:'Margareth',country:'England'}, {name:'Hege',country:'Norway'}, {name:'Joe',country:'Denmark'}, {name:'Glustav',country:'Sweden'}, {name:'Birgit',country:'Denmark'}, {name:'Mary',country:'England'}, {name:'Kai',country:'Norway'} ]; $scope.price = 58; }); </script> </body> </html>
AngularJS provides filters to transform data:
--> currency : Format a number to a currency format.
--> date : Format a date to a specified format.
--> filter : Select a subset of items from an array.
--> json : Format an object to a JSON string.
--> limit : To Limits an array/string, into a specified number of elements/characters.
--> lowercase : Format a string to lower case.
--> number : Format a number to a string.
--> orderBy : Orders an array by an expression.
--> uppercase : Format a string to upper case.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.