filters in angular js

Filters in angularjs?

AngulaJS having following filters

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.

limitTo 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.

Ex:

<div ng-app=”AngularApp” ng-controller=”AngularCtrl”>

<p>The name is {{ lastName | uppercase }}</p>

</div>

<script>

angular.module(AngularApp, []).controller(AngularCtrl, function($scope) {

    $scope.firstName = “John”,

    $scope.lastName = “Doe”

});

</script>

Ex:

The above code filter the and display the last name with uppercase. Similarly we can do for different filters by placing the filter name after pipe symbol.

Leave a comment

Your email address will not be published. Required fields are marked *