Filters can be added to expressions and directives using a pipe character (|).

AngularJS filters syntax

AngularJS filters can be used to transform data:

FilterDescription
currencyFormat numbers into currency format.
filterSelects a subset from array items.
lowercaseFormat the string to lowercase.
orderByOrder an array based on an expression.
uppercaseFormat string to uppercase.

AngularJS filters example

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://cdn.bootcss.com/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>

<div ng-app="myApp" ng-controller="personCtrl">

<p>姓名为 {{ lastName | uppercase }}</p>

</div>

<script>
angular.module('myApp', []).controller('personCtrl', function($scope) {
    $scope.firstName = "John",
    $scope.lastName = "Doe",
    $scope.fullName = function() {
        return $scope.firstName + " " + $scope.lastName;
    }
});
</script>

</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance