我想要显示一个Fi还原模型,其中包含一个概要文件名和一个带有角6的描述标签的列表。
作为Firestore的新手,我了解到,我应该将其建模如下:在这里输入图像描述
members {
id: xyz
{
name: Jones;
hashtag: {
global: true,
digital: true
}
...
}
现在,我试图了解如何在组件列表中显示每个hashtag属性的键。我的当前代码总是将对象对象显示为结果。我的组件代码是:
import { Component } from '@angular/core';
import { AngularFirestore } from 'angularfire2/firestore';
import { Observable } from 'rxjs';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
items$: Observable<any[]>;
constructor(db: AngularFirestore) {
this.items$ = db.collection('Members').valueChanges();
console.log(this.items$);
}
}
我的模板代码是:
<p>names and their interests</p>
<div *ngFor="let item of items$ | async">
<h4>{{item.name}}</h4>
<ul>
<li>{{item.hashtag}}</li>
</ul>
</div>
我怎么才能解决这个问题?
发布于 2018-09-25 12:28:26
认为你在寻找(角6.1):
<li *ngFor="let hashtag of item.hashtag| keyvalue">
{{hashtag.key}}:{{hashtag.value}}
</li>这样做的目的是获取item.hastag的键和值,并让它们在hastag中使用。
https://stackoverflow.com/questions/52498105
复制相似问题