Array sorting in angularjs -


i have array of following structure --

the structure of array following -

    [         {key:12,value:[{e:1,c:2,d:3},{e:34,c:45,d:90},{e:23,c:89,d:34}]},         {key:25,value:‌​[{e:12,c:22,d:32},{e:34,c:45,d:90},{e:23,c:89,d:34}]}     ]  

i have sort columns. how can go it?

ng-repeat array looks following --

    <tbody>         <tr ng-repeat = "key in array track $index">         <td>key.key</td>         <td>{{key.value[0].e}}</td>         <td>{{key.value[1].e}}</td>         <td>{{key.value[2].e}}</td>         </tr>    </tbody> 

you can use orderby filter component of ng module of angularjs. example, if want sort columns according key parameter of key variable, can following,

   <tbody>         <tr ng-repeat = "key in array track $index | orderby:'key'">         <td>key.key</td>         <td>{{key.value[0].e}}</td>         <td>{{key.value[1].e}}</td>         <td>{{key.value[2].e}}</td>         </tr>    </tbody> 

for more information, can read orderby documentation.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -