Question

I have the following code

<tr>
 <th ng-click="predicate='-name'; reverse=false;">Name</th>
 <th ng-click="predicate='age'; reverse=true;">Age<th>
<tr>
<tr ng-repeat="user in users | orderBy:predicate:reverse">
 <td>{{user.name}}<td>
 <td>{{user.age}}</td>
</tr>

My aim here is whenever i click on the table header, then the corresponding column has to be sorted based on particular predicate and reverse. And that is happening perfectly. But I have a scenario where, when i click on an external object, then my age value in table changes here and hence as a result the table sort order is getting disturbed. But i don't want sort to get disturbed. How can i skip table to not obey sort on other actions and have it only on click of table column headers? Can anyone help me with this?

Était-ce utile?

La solution

I don't think this is possible. Whenever "users" changes, Angular will notice (since that scope property (i.e., "users") is bound (one-way data binding) to the ng-repeat directive), and Angular will update the view.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top