3
我需要爲我所用排序依據過濾表中的數據進行排序,並正從最後一排上面 plunker例如分類將更加explanable表使用排序依據排序工作不正常
HTML:
<table class="friends">
<thead>
<tr class='table-head'>
<th scope="col">Candidate Name</th>
<th scope="col" ng-repeat="a in [1,2,3,4]" ng-click="sortBy('candidateData.rating')"><a style="cursor:pointer">Round{{a}}</a></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="candidate in aCandidateDetails| orderBy:propertyName:reverse">
<td>
<div>{{candidate.name}}</div>
</td>
<td ng-repeat="candidateData in candidate.ratings">
<div ng-if="candidateData.rating">
{{candidateData.rating}}
</div>
<span ng-if="!candidateData.rating"> - NA - </span> </td>
<td data-title="Status">
<div>{{candidate.interviewStatus}}</div>
</td>
<td><a href="" ng-model='candidate' ng-click="fnCandidateFeedbackDetails(candidate.uniqueId,candidate._id)"><i class="fa fa-info-circle" aria-hidden="true"></i></a></td>
</tr>
</tbody>
</table>
JS:
$scope.propertyName = 'name';
$scope.reverse = true;
$scope.sortBy = function(propertyName) {
$scope.reverse = ($scope.propertyName === propertyName) ? !$scope.reverse : false;
$scope.propertyName = propertyName;
};
JSON:
$scope.aCandidateDetails = [{
name: "a",
ratings: [{
round: 1,
rating: 3,
feedback: "something",
interviewer: "abc",
roundStatus: "selected"
},
{
round: 2,
rating: 5,
feedback: "something",
interviewer: "abc",
roundStatus: "selected"
}, {
round: 3,
rating: 4,
feedback: "something",
interviewer: "abc",
roundStatus: "selected"
}, {
round: 4,
rating: 1,
feedback: "something",
interviewer: "abc",
roundStatus: "selected"
}
]
}, {
name: "b",
ratings: [{
round: 1,
rating: 5,
feedback: "something",
interviewer: "abc",
roundStatus: "selected"
},
{
round: 2,
rating: 4,
feedback: "something",
interviewer: "abc",
roundStatus: "selected"
}, {
round: 3,
rating: 3,
feedback: "something",
interviewer: "abc",
roundStatus: "selected"
}, {
round: 4,
rating: 2,
feedback: "something",
interviewer: "abc",
roundStatus: "selected"
}
]
},{
name:"c",
ratings: [{
round: 1,
rating: 1,
feedback: "something",
interviewer: "abc",
roundStatus: "selected"
},
{
round: 2,
rating: 1,
feedback: "something",
interviewer: "abc",
roundStatus: "selected"
}, {
round: 3,
rating: 1,
feedback: "something",
interviewer: "abc",
roundStatus: "selected"
}, {
round: 4,
rating: 1,
feedback: "something",
interviewer: "abc",
roundStatus: "selected"
}]
}]
如果我們上一輪的點擊,那麼它應該來挑選基於等級按降序排列未發生
任何幫助表示讚賞
謝謝:) 我做了同樣的方式,它爲我工作 –