I have a list of objects from Firebase using the angularFire
implicit data sync, and I'd like to render their unique ids (for use in urls) along with the other data properties using ng-repeat
. Can I make angularFire
return in such a way that I have access to the object ids within ng-repeat
, the same way that members of an angularFireCollection
have an $id
property? If not, what is the right way to accomplish this? Hypothetical code (that doesn't work):
Controller:
myApp.controller('ItemListCtrl', ['$scope', 'angularFire',
function ItemListCtrl($scope, angularFire) {
var ref = new Firebase(firebaseUrl);
angularFire(ref, $scope, 'items');
}
]);
View:
<div ng-repeat="item in items" >
<a href="" ng-href="#/items/{{item.name()}}">{{item.text}}</a>
</div>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…