gpt4 book ai didi

Angular firestore creating saving data under ID field of type map(角度FireStore在类型为map的ID字段下创建保存数据)

转载 作者:bug小助手 更新时间:2023-10-24 21:03:11 25 4
gpt4 key购买 nike



I am trying to create field from angular component to add to firestore collection. Fields are UserId and Details. Details is in a form in html but userid comes from parent component , and suppose to be saved in the collection. When form is submitted, fields are created but userID is under 'ID' of type map. How do I save only as userID. It is getting the 'ID' from the main component where declared Opendialog
service

我正在尝试从角度组件创建字段,以添加到火库集合。字段为UserID和Detail。详细信息以html格式显示,但userid来自父组件,并假定保存在集合中。提交表单时,将创建字段,但UserID位于类型MAP的‘ID’下。如何仅保存为USERID。它正在从主组件获取‘ID’,其中声明了OpenDialog服务


 addDetails( id: string,details: Users) {
this.db.collection('detailscollection')
.add(details)
.then(res => {
console.log('Successfully');
})
.catch((error) => {
console.log('Error ' ,error);
});
}

Main Component

主要组成部分


 openDialog() {
const MatDialogRef = this.dialog.open(DetailsDialogComponent, {
height: '220px',
width: '250px',
data: {
userID: this.id,
}
}
);

DetailsDialogComponent.ts

DetailsDialogComponent.ts


  ngOnInit(){     

this.userForm = new FormGroup({
'details' : new FormControl(),
})
}
onSubmit() {

let details:Clients = {
id: this.data,
notes: this.userForm.value.user,
}
this.userService.addDetails(this.id, details);

}

更多回答
优秀答案推荐
更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com