我在 firebase 上有一个对象,其中有一系列针对特定文档上每个用户的对象。每个用户的对象初始对象键是他们的 UID。我正在尝试检查用户是否有对象。问题是动态传递 userId
找不到正确的路径:
this.userId = this._auth.currentUserId;
<p *ngIf="tenancy_offer.application.members.userId">UserId exists</p>
这将返回 null,因为它正在查找 userId
的键而不是用户的实际 ID。那么,如何将变量作为对象路径的一部分动态传递?
最佳答案
如果 userId
在 mebers objetc 中是散列(如 onq9wawO7...
)然后尝试
<p *ngIf="tenancy_offer.application.members[userId]">UserId exists</p>
关于javascript - 在 Angular 5 HTML 中将变量添加到对象路径中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54551920/