如何从 AngularFire 中的对象数组中提取键名 [英] How to pull key name from array of objects in AngularFire

查看:24
本文介绍了如何从 AngularFire 中的对象数组中提取键名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮我从内容 ($Id) 中提取唯一的对象名称.我可以使用 ng-repeat 遍历模板中的 $scope.data ,但我无法获得该数组的名称.需要它来构建 URL 引用.

简而言之,我如何获得2015-02-27T20:24:11-06:00"?我可以拉出 item.count、item.handle、item.img_url,但是 {{item.$id}} 不起作用.

obj.$asArray();

obj.$asObject();

解决方案

如果你获取数据 $asArray() 并将它保存在 $scope.data 你应该只需能够按照您的描述获得 $id.

<p>id: {{item.$id}}</p>

但是,我不禁注意到您在 $Id 中的大小写是错误的.

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();

解决方案

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.

这篇关于如何从 AngularFire 中的对象数组中提取键名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆