I have a very simple array of objects and I want to sort it using $filter('orderBy')
in javascript. Somehow it doesn't seem to work. jsFiddle
Here is the code
var app = angular.module('myApp', []);
app.controller('myController', function($scope, $filter){
var person = [{
name : "Saras"
},
{
name : "Arya"
}];
$filter('orderBy')(person, 'name');
console.log(person);
});
I don't understand why I can't get this to work? Help is appreciated. And the solution should be in JS not in HTML.