Filter Sort by date

Description

The following code shows how to use filter sort by date.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--   w w  w  .  j  ava2 s  .  c  om-->
<body>
  <div ng-app>
    <div ng:controller="Main">
      <div ng:repeat="(id, i) in items | orderBy:'date'">{{id}}: {{i.date | date}}</div>
    </div>
</div>
<script type='text/javascript'>
function Main($scope) {
    $scope.items = {
        0: {date: new Date('12/23/2013')},
        1: {date: new Date('12/23/2011')},
        2: {date: new Date('12/23/2010')},
        3: {date: new Date('12/23/2015')}
    };
}
</script>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities