I know that in angularJS there is some built in filter: for example
But I don\'t want to us
Use Array.sort. Refer to the example below
var app = angular.module('so', []);
app.controller('MyCtrl', function($scope) {
$scope.students = [{'name': 'student'}, {'name': 'john'}, {'name': 'austin'}, {'name': 'doe'}];
});
app.filter('filterByName', function () {
return function (item) {
return item.sort((a,b) => a.name.localeCompare(b.name))
};
});
- {{student.name}}