2017-03-08 53 views
0

我與嵌套表 實例數據的工作:角 - 類別嵌套表

$scope.building = 
    [ 
     { 
     "id": 1, 
     "name": "first", 
     "ownBlock": [ 
      { 
      "id": 1, 
      "name": "Block 1" 
      }, 
      { 
      "id": 2, 
      "name": "Block 2" 
      } 
     ] 
     }, 
     { 
     "id": 2, 
     "name": "second", 
     "ownBlock": [ 
      { 
      "id": 3, 
      "name": "Block 1" 
      }, 
      { 
      "id": 4, 
      "name": "Block 2" 
      } 
     ] 
     } 
    ] 

當我有點ID 2 ownBlock,它將ID爲1太

<tr ng-repeat="block in data.ownBlock| orderBy : sortColumn.Field : sortColumn.Order">.... </tr> 

的子數據進行排序我知道原因,但我沒有解決方案來解決這個問題。希望它可以幫助

+0

什麼實際的排序順序,你在你的數據想? –

+0

你想不要排序子數據嗎? –

+0

感謝您的回答,我想對孩子數據bro進行排序。但我的問題是,當我排序的父母的Id 2名稱「第二」的子數據,ID 1名稱的子數據先排序太多,我不想這樣,我只想只有子女的數據的ID 2排序 – Dakota

回答

2

,如果你不希望孩子進行排序試試這個

$scope.building = $filter('orderBy')($scope.building,'id');