data-ng-repeat and orderBy
Description
We can use data-ng-repeat
and orderBy
to
sort an array.
Example
<!DOCTYPE html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js">
</script><!--from w ww . j a v a 2s . com-->
</head>
<body>
<div data-ng-init="names=[{name:'XML',city:'W3C'},{name:'Java',city:'Oracle'},{name:'Tutorial',city:'java2s.com'}]">
<ul>
<li data-ng-repeat="myObject in names| orderBy:'name'">{{myObject.name}} - {{myObject.city}}</li>
</ul>
</div>
</body>
</html>