2017-07-04 5 views
0

スコープ変数にオブジェクトの配列があり、特定のオブジェクト(日付フィールド)に対してこの配列を並べ替える必要があります。表示。私は以下のロジックを記載しているanglejsのコントローラー内の特定のフィールドに関してオブジェクトの配列をソートする方法

<ion-option-button role="button" data-ng-click="save(data)"></ion-option-button> 

コントローラー:

$scope.save = function(data) { 
    var action='save'; 
    //service call happens and response is returned 

    if (response.isSuccessful === true && response.responseCode == "1") { 

     vm.data = moveElementInArray(vm.data, data, 0); 
     //perform sorting with respect to a date field after moving to index 0 , vm.data contains the array objects 
    } 
}; 

答えて

0

する

arr = $filter('orderBy')(arr, 'Date', true); 

documentation

を参照してください$フィルタを使用してみてください
関連する問題