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);
}
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!