How to pull key name from array of objects in AngularFire

痴心易碎 提交于 2019-12-12 06:04:51

问题


Can someone help me pull the unique object name from contents ($Id). I'm able to loop over $scope.data in my template with ng-repeat but I can't get the name of that array. Need this to build a URL reference.

In short, how do I get "2015-02-27T20:24:11-06:00"? I can pull out item.count, item.handle, item.img_url, but {{item.$id}} doesn't work.

obj.$asArray();

obj.$asObject();


回答1:


If you fetch the data $asArray() and save it on $scope.data you should simply be able to get the $id as you describe.

<div ng-repeat="item in data">
  <p>id: {{item.$id}}</p>
</div>

However, I can't help but notice that your casing in $Id is wrong.



来源:https://stackoverflow.com/questions/28862462/how-to-pull-key-name-from-array-of-objects-in-angularfire

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!