AngularJS Tutorial - Filter to sort object by property








The following code shows how to use Filter to sort object by property.

Example


<!doctype html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.js"></script>
</head><!--from w w  w  .ja  va 2  s  . c  o  m-->
<body>

  <div>
    <h5>orderBy:</h5>
    <div>
      {{ [{
          'name': 'Z',
          'status': 'onLine'
          }, {
          'name': 'Q',
          'status': 'offLine'
          }, {
          'name': 'N',
          'status': 'justLoggedIn'
          }] | orderBy: '+name' }}
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: