AngularJS - How to orderBy the value of an array-like object in an ng-repeat AngularJS - How to orderBy the value of an array-like object in an ng-repeat angularjs angularjs

AngularJS - How to orderBy the value of an array-like object in an ng-repeat


To sort array in ngRepeat you can use orderBy filter but it works only with arrays, so you should use array in ngRepeat.

It will be something like this in controller:

$scope.myData = [    {        key:    "01",        value:  "Cranberry"    },    {        key:    "02",        value:  "Banana"    },    {        key:    "03",        value:  "Apple"    }];

and in html:

<div class="item" ng-repeat="item in myData|orderBy:'value'">{{item.value}}</div>