【发布时间】:2020-11-29 12:37:03
【问题描述】:
我正在尝试按照视频来实现产品列表,但该列表没有显示我在firebase 数据库中列出的产品。有人可以帮忙吗?
product-form.component.html
<div class="form-group">
<label for ="category">Category</label>
<select id="category" class="form-control">
<option value=""></option>
<option *ngFor="let c of categories$ | async" value="c.$key">
{{ c.name }}
</option>
</select>
</div>
product-form.component.ts
export class ProductFormComponent implements OnInit {
categories$;
constructor(categoryService: CategoryService) {
this.categories$= categoryService.getCategories();
}
ngOnInit() {
}
}
category.service.ts
export class CategoryService {
constructor(private db:AngularFireDatabase) { }
getCategories() {
return this.db.list('/categories');
}
}
我在 firebase 实时数据库中手动输入了类别,看起来像这样。 类别
【问题讨论】:
标签: angular firebase firebase-realtime-database