Click here to Skip to main content
15,921,295 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
I have to arrange status(P,A) according to date in ascending order but it showing me in same order as they are inserted. but i want to arrange accourding to date.



$scope.students{
"name": "sample",
"def": [
{
"setId": "arun",
"Date": [
{
"day": "2016-09-28",
"status": "A"
},
{
"day": "2016-09-27",
"status": "P"
},
{
"day": "2016-09-29",
"status": "A"
},

{
"day": "2016-09-26",
"status": "P"
}
]
},
{
"name": "deepak",
"Date": [
{
"day": "2016-09-28",
"status": "P"
},
{
"day": "2016-09-27",
"status": "A"
},
{
"day": "2016-09-29",
"status": "A"
},

{
"day": "2016-09-26",
"status": "P"
},
]
}
]};

HTML
<table>
<tbody>
  <tr>
    <td>S.No.</td>
    <td>NAME</td>
    <td>26-9-2016</td>
    <td>27-9-2016</td>
    <td>28-9-2016</td>
    <td>29-9-2016</td>
  </tr>
  <tr data-ng-repeat="student in students" st-select-row="row">
        <td data-ng-bind="$index+1"></td>
        <td data-ng-bind="student.name"></td>
        <td data-ng-repeat="data in student.Date" data-ng-bind="data.status"></td>
  </tr>
</tbody>


C#
WANT IN THIS WAY :-

 1. Name   | 26-9-2016 | 27-9-2016 | 28-9-2016 | 29-9-2016|
 2. Arun   | P         | P         | A         | A        |
 3. dDepak | P         | A         | P         | A        |


C#
GETTING IN THIS WAY :-

  1. Name   | 26-9-2016 | 27-9-2016 | 28-9-2016 | 29-9-2016|
  2. Arun   | A         | P         | A         | p        |
  3. Deepak | P         | A         | A         | P        |


What I have tried:

changes in ng-repeat, use filter & orederby.
Posted
Updated 2-Oct-16 19:44pm

1 solution

use Angular orderby [^]
HTML
<tr ng-repeat="student in students | orderBy:student:Date">
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900