I have the following form
in Angular created with FormBuilder
:
constructor(private fb: FormBuilder) {
this.myForm = fb.group({
'name': ['', [Validators.required],
'surname': ['', [Validators.required],
'email': ['', [validateEmail]],
'address': fb.group({
'street': [''],
'housenumber': [''],
'postcode': ['']
}, { validator: fullAddressValidator })
});
}
Does exist a way to programmatically append new fields such as FormControl
or new FormGroup
to myForm
?
I mean if I want to add new fields on demand or on some conditions, how to add items to the same form that is created the first time in the constructor
?
question from:
https://stackoverflow.com/questions/41588325/how-to-append-new-formgroup-or-formcontrol-to-form 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…