noobcoder noobcoder - 1 year ago 81
AngularJS Question

AngularJS orderby not working as expected

I am using Angular directive to orderBy on table rows, with the data coming as an array of objects from a service.

<tr ng-repeat="album in vm.albums | orderBy:">


Here's what my
array looks like:

vm.albums ---> [>Object1, >Object2, >Object3......]

And each object looks like the foll:

Object1 ---> {slug: "my-title", data: Object}
Object2 ---> {slug: "beta-title", data: Object}
Object3 ---> {slug: "alpha-title", data: Object}

And the object
or any object in the vm.albums array looks like the following: ---> {title: "My Title", date: "2015-04-06", type: "Blue", username: 'rust'} ---> {title: "Beta Title", date: "2012-04-07", type: "Orange", username: 'badname'} ---> {title: "Alpha Title", date: "2013-09-06", type: "Lemons", username: 'xerox'}

I still don't get the right sorted
in my table using the
I am using. Not sure what I am doing wrong. Any clue ?

Answer Source


<tr ng-repeat="album in vm.albums | orderBy: 'data.title'">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download