[英]how can I set lists and also push lists in angular 4 firebase
更好的結構將是:
在您的組件中:
constructor(private resturantService:ResturantService){}
yourPushButton(resturant){
// I presume resturant is an object
resturant['branches']='';
resturant['items']='';
this.resturantService.pushResturant(resturant)
}
在您的服務 ResturantService 中:
constructor(private db: AngularFireDatabase){} <--- if you use angularFire2
pushResturant(resturant){
const itemsRef = this.db.object('resturants/${resturant.name}')
itemsRef.update(resturant)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.