【发布时间】:2017-10-23 04:51:02
【问题描述】:
我有多个要循环的 firebase 项目,它们有名称、categoryId、lat、lon。
我正在尝试计算距 2 lat,lon 的距离(一个是 firebase 中的那个),另一个是用户的位置。
这一切都很好,我也可以很好地计算出来。但是,如何将新变量注入/映射到我订阅的 firebase 数组中?
this.categoryId = this.navParams.get('categoryId');
afoDatabase.list('/list', {query: {
orderByChild: "categoryId",
equalTo: parseInt(this.categoryId)
}}).subscribe(listItems => {
this.items = listItems; //need to add distance within array
loadingPopup.dismiss().catch(() => {});
});
例如,我有一个名为 distance 的变量,它计算所有内容并具有值。如何在 this?items 中添加它 - 这样我就可以从 HTML 端调用它?
感谢您的帮助:)
【问题讨论】:
标签: angularjs arrays firebase dictionary ionic-framework