Rodney Wormsbecher
Rodney Wormsbecher

Reputation: 927

angular 1.5 orderBy doesn't work

I have an array with objects in it which I would like to sort within my ng-repeat, but no matter which field I get it doesn't seem to respond to anything.

I have the following array:

[{"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"}]

The controller code:

  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);
                });
            });

        }

and this is my 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>

I have checked the following post but none of the solutions worked for me. (Angular - Can't make ng-repeat orderBy work)

any help would be much appreciated. Cheers!

Upvotes: 0

Views: 43

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222582

Jus use planTitle

 <a class="list-group-item newsItem-pointer" ng-repeat="task in vm.tasksToShow | limitTo: vm.amountOfTasksToShow | orderBy: 'planTitle'">

Upvotes: 0

Related Questions