Ich brauche Tabellendaten zu sortieren, für die i orderBy Filter verwendet, und es wird von den letzten Zeile über Plunker Beispiel sortiert bekommen wird viel explanableSortiertisch mit orderBy nicht wie erwartet funktioniert
html sein:
<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"
}]
}]
Wenn wir auf rund klicken dann sollte es in absteigender Reihenfolge nach Bewertung sortieren, die nicht geschieht
Jede Hilfe ist willkommen
danke :) Ich tat auf die gleiche Weise und es hat für mich funktioniert –