2017-01-27 30 views
0
self.records: [ 
    { 
    "Reg_code": 10001025, 
    "Name": "Chandan Kumar Penta", 
    "staticColumn": { 
     "Check": "Check1", 
     "HHHHH": "" 
    } 
    }, 
    { 
    "Reg_code": 10001290, 
    "Name": "test_B2 ", 
    "staticColumn": { 
     "Check": "Check2", 
     "HHHHH": "" 
    } 
    }, 
    { 
    "Reg_code": 10001028, 
    "Name": "Ronny Lewis", 
    "staticColumn": { 
     "Check": "Check3", 
     "HHHHH": "" 
    } 
    } 
] 

這是我的JSON對象。我想根據對AngularJS中的進行排序。請幫忙。排序AngularJS

+0

你的意思是,你需要通過檢查來篩選記錄? –

+0

@Yogiraj基於檢查意味着在stationColumn對象中存在的每個對象中的關鍵檢查? – Dhiraj

+0

請在這裏檢查http://plnkr.co/edit/S5PwRWQFmQekoPPFFpGk?p=preview –

回答

3

你可以做,

<div class="adaptions" ng-repeat="record in records | orderBy:'staticColumn.Check' "> 

DEMO

var app = angular.module('todoApp', []); 
 

 
app.controller("dobController", ["$scope", 
 
    function($scope) { 
 
    $scope.records = [ 
 
    { 
 
    "Reg_code": 10001025, 
 
    "Name": "Chandan Kumar Penta", 
 
    "staticColumn": { 
 
     "Check": "Check4", 
 
     "HHHHH": "" 
 
    } 
 
    }, 
 
    { 
 
    "Reg_code": 10001290, 
 
    "Name": "test_B2 ", 
 
    "staticColumn": { 
 
     "Check": "Check2", 
 
     "HHHHH": "" 
 
    } 
 
    }, 
 
    { 
 
    "Reg_code": 10001028, 
 
    "Name": "Ronny Lewis", 
 
    "staticColumn": { 
 
     "Check": "Check3", 
 
     "HHHHH": "" 
 
    } 
 
    } 
 
]; 
 
    
 
    
 
    } 
 
]);
<!DOCTYPE html> 
 
<html ng-app="todoApp"> 
 

 
<head> 
 
    <title>Sample</title> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script> 
 
</head> 
 
<body ng-controller="dobController"> 
 
<div class="adaptions" ng-repeat="record in records | orderBy:'staticColumn.Check' "> 
 
    <ul> 
 
     <li >{{ record.staticColumn.Check }}</li> 
 
    </ul> 
 
</div> 
 
    
 
</body> 
 

 
</html>

+0

有助於解決 – Dhiraj

+0

Thanx Sajeetharan ....它的工作原理... –