问题描述
我正在尝试实现一个编辑表单,该表单显示从数据库获取的值数据,但是问题是,当我尝试将formGroup
与formBuilder
一起使用时,我不能输入@INPUT构造函数中的数据我得到未定义的数据。
如何在formbuilder构造函数中使用@input数据?
export class EditModalComponent implements OnInit {
checkoutForm;
@Input() product //this is the data from the father component
closeResult = '';
ngOnInit() {
}
constructor(private modalService: NgbModal,private formBuilder: FormBuilder) {
this.checkoutForm = this.formBuilder.group({
imageURL: this.product.imageURL,// i get undefined
name: this.product.name,// i get undefined
category: this.product.category,// i get undefined
price: this.product.price,// i get undefined
});
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)