AngularJS orderBy filter not working as expected -
i'm trying show array ($scope.stored_questions_clusters
) sorted in descending order position of each element, problem don't desired result.
in example ng-repeat = "question cluster stored in clusters questions | orderby '- question_cluster.position'"
, @ each iteration create panel bootstrap print position, expect list sorted position, don't this...
here code use:
<div style="margin-top:30px;" ng-show="mostrarpreguntas==true"> <div ng-repeat="question_cluster in stored_questions_clusters | orderby:'-question_cluster.position'" class="col-xs-8 col-xs-offset-2"> <div class="panel panel-default"> <div class="panel-heading"> <div class="row"> <div class="col-xs-11"> <h3>{{question_cluster.position}}.- {{question_cluster.title}}</h3> </div> . . .
and result:
this console.log of each element:
you want use ng-repeat="question_cluster in stored_questions_clusters | orderby:'-position'"
this sort question_clusters
in descending order
have @ first example on angulars order documentation
Comments
Post a Comment