{"id":64,"date":"2016-01-20T09:32:59","date_gmt":"2016-01-20T09:32:59","guid":{"rendered":"http:\/\/muthu.co\/?p=64"},"modified":"2021-01-02T14:06:04","modified_gmt":"2021-01-02T14:06:04","slug":"how-to-render-ng-repeat-in-reverse-order","status":"publish","type":"post","link":"http:\/\/write.muthu.co\/how-to-render-ng-repeat-in-reverse-order\/","title":{"rendered":"How to render ng-repeat in reverse order"},"content":{"rendered":"

Many times you would like to render the array contents in reverse when using ng-repeat. You can do that with a simple single line code which uses\u00a0the\u00a0slice and reverse method.<\/p>\n

<tr ng-repeat=\"subs in subjects.slice().reverse()\">\r\n\r\n<\/tr><\/pre>\n

The disadvantage to this way of printing the data is that the original array contents get reversed taking up your systems precious computational resources. There is also a better way of achieving the same\u00a0using the orderBy filter.<\/p>\n

<tr ng-repeat=\"subs in subjects| orderBy:'-' \">\r\n     \r\n<\/tr><\/pre>\n

Notice the use of orderBy with ‘-‘.<\/p>\n

  <\/p>\n","protected":false},"excerpt":{"rendered":"

Many times you would like to render the array contents in reverse when using ng-repeat. You can do that with a simple single line code which uses\u00a0the\u00a0slice and reverse method. <tr ng-repeat=”subs in subjects.slice().reverse()”> <\/tr> The disadvantage to this way of printing the data is that the original array contents get reversed taking up your […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,2],"tags":[45,52,3],"_links":{"self":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/64"}],"collection":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":1,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"predecessor-version":[{"id":1668,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/64\/revisions\/1668"}],"wp:attachment":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}