私はユーザーの配列を持っています。最初に読み込まれたときに姓で並べ替えられた ng-repeat を持ちたいです。新しいユーザーが追加された後、ng-repeat を日付順に並べ替え、次に姓を追加します。基本的に、最新のユーザーを ng-repeat のトップに押し上げたいと思っています。
<th ng-click="menuFilter('lastName', 1);">
<div ng-class='{"menuSort":sortColumn==1}'>Name <span ng-show="share.orderByField == 'lastName'">
</div>
</th>
<tr ng-repeat="user in users | orderBy:orderByField:reverseSort"></tr>
私のJSで...
_this.sortColumn = 1;
_this.orderByField = 'lastName';
_this.reverseSort = false;
_this.menuFilter = function(section, column) {
_this.orderByField = section;
_this.reverseSort = !_this.reverseSort;
_this.sortColumn = column;
};
//my attempt to reset the order by created at date
if( _this.isRefreshing ) {
_this.orderByField = ['createdAt', 'lastName'];
}
基本的に、このコードは何もしていません。HTML のステップが足りないと思います。
ありがとう!