简体   繁体   中英

How to sort table list as per requirement using Angular.js

I am trying to sort the table list using Angular.js but it's not happening like that. My code is below:

<tbody id="detailsstockid">
<tr ng-repeat="c in clickSummary | orderBy:['-total','+rest_name']">
  <td>{{$index+1}}</td>
  <td>{{c.rest_name}}</td>
  <td>{{c.page_hit}}</td>
  <td>{{c.map_hit}}</td>
  <td>{{c.gallery_hit}}</td>
  <td>{{c.phone_hit}}</td>
  <td>{{c.web_hit}}</td>
  <td>{{c.total}}</td>
</tr>   
</tbody>

Here I need to sort the list as per total and rest_name filed . I need to sort as per total column value in descending order and if there are same value in total column then it should sort as per rest_name . But in my case I am getting the output like below.

在此处输入图片说明

In this picture you can see one has total column value 11 but it's coming last which should come fast.

It is sorting by string comparison rather than number comparison. That means you're not presenting the data as numbers.

See the documentation here

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