在 ng-repeat 中以与 Firebase 相反的顺序显示项目
Display items in reverse order from Firebase in ng-repeat
我的问题类似于下面的SO问题
Reverse order of items pulled from database in ng-repeat
但是,我正在使用以下方法绑定特定 AccountID 的所有交易
var syncObject = $firebaseObject(fb.child("members/" + fbAuth.uid + "/accounts/" + $scope.AccountId));
syncObject.$bindTo($scope, "data");
与上面提到的 SO 问题和我的不同之处在于,我使用 $firebaseObject
来绑定数据(三向数据绑定)。
那么我怎样才能倒序显示交易列表呢?我想在视图顶部显示最近的交易
在此先感谢您的帮助!
在这种情况下,您应该使用 $firebaseArray,因为它可以让您根据需要进行排序:
Javascript
var ref = fb.child("members/" + fbAuth.uid + "/accounts/" + $scope.AccountId);
$scope.data = $firebaseArray(ref);
HTML
<div data-ng-repeat="child in data | orderBy:'FIELD_TO_SORT_BY':true>
<!-- other elements -->
</div>
我的问题类似于下面的SO问题
Reverse order of items pulled from database in ng-repeat
但是,我正在使用以下方法绑定特定 AccountID 的所有交易
var syncObject = $firebaseObject(fb.child("members/" + fbAuth.uid + "/accounts/" + $scope.AccountId));
syncObject.$bindTo($scope, "data");
与上面提到的 SO 问题和我的不同之处在于,我使用 $firebaseObject
来绑定数据(三向数据绑定)。
那么我怎样才能倒序显示交易列表呢?我想在视图顶部显示最近的交易
在此先感谢您的帮助!
在这种情况下,您应该使用 $firebaseArray,因为它可以让您根据需要进行排序:
Javascript
var ref = fb.child("members/" + fbAuth.uid + "/accounts/" + $scope.AccountId);
$scope.data = $firebaseArray(ref);
HTML
<div data-ng-repeat="child in data | orderBy:'FIELD_TO_SORT_BY':true>
<!-- other elements -->
</div>