Reputation: 33
I am trying to implement the product list by following the video, but the list doesnt display the products that I have listed in the firebase
database. Can someone help?
<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>
export class ProductFormComponent implements OnInit {
categories$;
constructor(categoryService: CategoryService) {
this.categories$= categoryService.getCategories();
}
ngOnInit() {
}
}
export class CategoryService {
constructor(private db:AngularFireDatabase) { }
getCategories() {
return this.db.list('/categories');
}
}
I have manually entered the categories in the firebase realtime database looks like this. categories
Upvotes: 1
Views: 1294
Reputation: 22203
Try like this:
getCategories() {
return this.db.list('/categories').snapshotChanges();
}
Upvotes: 2