Filters

Filter are mainly used for modify the data. Filters can be added to expressions and directives using a pipe (|) character. Following Filter are use in AngularJs;
S.No.NameDescription
1uppercaseconverts a text to upper case text.
2lowercaseconverts a text to lower case text.
3currencyformats text in a currency format.
4filterfilter the array to a subset of it based on provided criteria.
5orderByorders the array based on provided criteria.

uppercase

uppercase filter are used for converting lower case text to upper case text. It is use to expression with pipe character.

Example

<div ng-app="" ng-controller="personController">
Enter first name:<input type="text" ng-model="name"><br/>
<p>The name is {{ name | uppercase }}</p>
</div>

<script>
function personController($scope) {
    $scope.name="Porter"
}
</script>

Example

Enter first name:
The name is PORTER

lowercase

lowercase filter are used for converting upper case text to lower case text. It is use to expression with pipe character.

Example

<div ng-app="" ng-controller="personController">
Enter first name:<input type="text" ng-model="name"><br/>
<p>The name is {{ name | lowecase }}</p>
</div>

<script>
function personController($scope) {
    $scope.name="PORTER"
}
</script>

currency

Add currency filter to an expression returning number using pipe character. Below we print total cost of items.

Example

<div ng-app="" ng-controller="personController">
<input type="number" ng-model="quantity"><br />
<input type="number" ng-model="price">

<p>Total = {{ (quantity * price) | currency }}</p>

</div>

<script>
function personController($scope) {
    $scope.quantity=10;
    $scope.price=1;

}
</script>