我仍然遇到OrderBy問題。數據來自於$ HTTP,看起來像這樣:根據搜索在AngularJS中OrderBy數組
[
{
"number":1,
"timetable": [
{
"name":"Station1",
"time":"2016-05-18T18:14:00.000Z"
},
{
"name":"Station2",
"time":"2016-05-18T18:18:00.000Z"
}
]
},
{
"number":2,
"timetable": [
{
"name":"Station1",
"time":"2016-05-18T18:24:00.000Z"
},
{
"name":"Station2",
"time":"2016-05-18T18:28:00.000Z"
}
]
}
]
所以我需要的是查看行,其中名稱是例如STATION2,我按時間需要他們才能。行不按時間排序,也不按數字排序。時間表行數不盡相同,所以行號也無濟於事。是否可以按照「OrderBy time where name ='Station2'」的樣式在ng-repeat內部對它們進行排序?
編輯: 目前我顯示的結果沒有任何順序,只有過濾。當前的PHP:
<tr ng-repeat="x in rows | limitTo:5">
<td>
<a href="aikataulu.php?n={{x.number}}">
<span class="label label-primary line-{{x.lineID}}">{{x.lineID}}</span> {{x.number}}
</a>
</td>
<td>
<span ng-repeat="y in x.timetable | limitTo:-1">{{y.name}}</span> //This is for showing the destination
</td>
<td>
<span ng-repeat="y in x.timetable | filter:{'name':'<?php echo $as;?>'}: true | limitTo:1">{{y.time | date:'HH:mm'}}</span>
</td>
</tr>
$ as to the station to be shown。所以,現在這個列表的順序直接來自JSON順序,所以它變化很大。
您可以在NG-使用GROUPBY和ORDERBY重複處理這一點。對你之後的佈局有一個更好的想法會很有幫助。 –
所以我在佈局後會顯示一個電臺的時間表,其中的數字將按照時間安排。 ** Station2 ** _Number_ _Time_ 1 18:18 2 18:28 –
有些嘲弄的HTML會比描述好得多。到目前爲止你做了什麼?很高興看到HTML和控制器。 –