javascript - 使用firebase在点击时显示详细信息
问题描述
我想通过点击 firebase 键的元素来显示地址的详细信息。我可以用 id 来做,但不能用 push 的键。感谢您的回访,因为我不知道如何使用密钥
我的地址表
服务地址
getSingleAdresse(id: number){
return new Promise(
(resolve, reject) =>{
firebase.database().ref('/adresse/' +id).once('value').then(
(data) => {
resolve(data.val());
}, (error) => {
reject(error);
}
);
}
);
}
列表页.html
<ion-card *ngFor="let item of adresses | keyvalue ; let i = index" (click)="onViewAdresse(i)">
<div><b>{{item.value.prenom}} {{item.value.nom}}</b></div>
</ion-card>
单个地址.ts(检索元素的页面)
ngOnInit() {
this.adresse = new Adresse ('','', '', '', '', '');
const id = this.route.snapshot.params['id'];
this.adresseService.getSingleAdresse(+id).then(
(adresse: Adresse) => {
this.adresse = adresse;
}
);
}
}
解决方案
推荐阅读
- javascript - 计算每张纸的页数/查找自动分页符 - Office JS - Excel
- python-3.x - if/elif 问题,它有效,但答案是错误的
- php - $ci = new $class() 在 CI 中加载需要 2 分钟
- amazon-web-services - 创建 AWS 预算提醒
- python - 使用 matplotlib 和 seaborn 在 Python 中限制箱形图中的范围
- python - 如何从 Python 中的数字中获取递减顺序列表?
- visual-studio-code - VSCode - 使用特定设置文件从 CLI 打开远程
- python - 来自谷歌搜索日期范围的 Python 网络爬虫
- spring-boot - 具有不同路径变量的相同端点
- javascript - 如何打印与json中另一个数组匹配的数据数组