Answer the question
In order to leave comments, you need to log in
What is the best way to accept data in a dialog box?
At the input of the dialog box I receive data:
constructor(@Inject(MAT_DIALOG_DATA) public data: { appid: number; raspprefect: Raspprefect }) {
}
ngOnInit() {
this.raspprefect = Object.assign({}, this.data.raspprefect);
this.form = this.formBuilder.group({
docnumber: [this.data.raspprefect.docnumber, [Validators.required]],
docdate: [null],
});
}
docnumber: [this.data.raspprefect.docnumber, [Validators.required]],
this.data.raspprefect.docnumber
- if there is no property if (data.type == 'edit') {
this.form.get("a").setValue(this.data.raspprefect.docnumber);
}
Answer the question
In order to leave comments, you need to log in
1) `docnumber: [this.data.raspprefect?.docnumber, [Validators.required]],` ( https://www.typescriptlang.org/docs/handbook/relea... )
2) `this.form. patchValue(this.data.raspprefect)` ( https://angular.io/api/forms/FormGroup#patchValue )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question