简体   繁体   中英

Ng-repeat orderBy value

How can I order my ng-repeat by the like_count in my json?

I have given it a bash but I am clearly missing something.

This is the repeat

item(ng-repeat="item in items | limitTo:3 | orderBy:like_count)

This is the data structure:

{
  "image_url" : "bde2cca8323d098edf43389119af7748.jpg",
  "title" : "This is the title",
  "like_count" : "15",
  "creator" : {
    "profile_img" : "john-doe.jpg",
    "username" : "JD",
    "url" : "/John-Doe",
    "first_name" : "John",
    "last_name" : "Doe",
    "location" : "Sydney, Australia"
  }
}, {
  "image_url" : "bjk23482301232234112d3232345343.jpg",
  "title" : "This is the title",
  "like_count" : "89",
  "creator" : {
    "profile_img" : "Jane-doe.jpg",
    "username" : "JD",
    "url" : "/Jane-Doe",
    "first_name" : "Jane",
    "last_name" : "Doe",
    "location" : "Melbourne, Australia"
  }
}

尝试这个..

ng-repeat="item in items | limitTo:3 | orderBy:'like_count'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM