Angularjs Examples

AJS Examples


AngularJS OrderBy Filter

In AngularJS orderby filter is used to set array order ascending or descending using an expression.

Syntax

{{ orderBy_expression | orderBy : expression : reverse}}

AngularJS OrderBy Filter Example

<html>
<head>
<title>My first AngularJS code</title>
<Script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js">
</Script>
<Script>
function setLimit($scope) {
    $scope.myArray = [12,32,4,21,3,54,3,2,6];
	$scope.identity = angular.identity;
}
</Script>
</head>
<body>
<div ng-app="">
<div ng-controller="setLimit"> 
Un-ordered Array : {{myArray}}
<p>Ordered Array Output : {{ myArray | orderBy:identity }}</p>

</div>
</div>
</body>
</html>
See live Example