我有一个包含对象的数组,我想在我的ng-repeat中进行排序,但无论我得到哪个字段,它似乎都没有响应。
我有以下数组:
[{"title":"test 2","planId":"waUVOGARMUyScTYtHI2p_5cAEI_f","dueDate":"","status":0,"assigneePriority":"85868377FP","planTitle":"plan 2","ownerId":"3c9a3683-5057-4e28-b348-0e1f23157bec"},{"title":"Visit the VET","planId":"PyHP00vnzkqxyheVWMOqhZcAFU0F","dueDate":"21-02","status":0,"assigneePriority":"85868377E(","planTitle":"Groep_test23","ownerId":"5cfb5e90-c5d1-4c83-acca-d86e4b912a0c"},{"title":"test","planId":"waUVOGARMUyScTYtHI2p_5cAEI_f","dueDate":"","status":0,"assigneePriority":"85868376\\:","planTitle":"plan 2","ownerId":"3c9a3683-5057-4e28-b348-0e1f23157bec"}]
控制器代码:
function getAllTasks() {
datacontext.graph.plannerGetAllTasks().then(function (tasks) {
datacontext.graph.plannerGetAllPlans().then(function (plans) {
var totalTasks = tasks.length;
for (var i = 0; i < totalTasks; i++) {
// append the plan name, owner Id to the tasks object.
var totalPlans = plans.length;
for (var j = 0; j < totalPlans; j++) {
if (plans[j].planId.indexOf(tasks[i].planId) != -1) {
tasks[i].planTitle = plans[j].title;
tasks[i].ownerId = plans[j].ownerId;
}
}
vm.tasks.push(tasks[i]);
}
changeListBucket(vm.currentTab);
});
});
}
这是我的HTML:
<div class="newsroom-tabs-bottom">
<a class="list-group-item newsItem-pointer" ng-repeat="task in vm.tasksToShow | limitTo: vm.amountOfTasksToShow | orderBy: task.planTitle">
<table style="width: 100%" class="dont-break-out">
<tr>
<td class="planner-icon-set-fixed-width default-text-colour">
{{$index + 1}}
</td>
<td style="width: 100%">
<span>
<span class="list-inbox-info-from-teamnews dont-break-out default-text-colour">{{::task.title}}</span>
</span>
<span class="list-inbox-info-subject dont-break-out default-text-colour">
{{::task.planTitle}}
<span style="float: right">{{ ::task.dueDate }}</span>
</span>
</td>
</tr>
</table>
</a>
</div>
我检查了以下帖子,但没有一个解决方案适合我。 (Angular - Can't make ng-repeat orderBy work)
任何帮助将不胜感激。干杯!
答案 0 :(得分:1)
Jus使用 <a class="list-group-item newsItem-pointer" ng-repeat="task in vm.tasksToShow | limitTo: vm.amountOfTasksToShow | orderBy: 'planTitle'">
Csrf-Token