I am using reactive from in Angular 7. I am creating child component for user profile edit. I have multiple role wise user pages. In all these pages user profile fields are common. So I have created user profile component in which I have an input parameter FormGroup:
constructor(private fb: FormBuilder) {
this.myForm = this.fb.group({
test: ['', Validators.required]
});
}
<user-profile [formGroup]="myForm" [submitted]="submitted"></user-profile>
Now I want to extend input FromGroup to add user profile fields. For ex, I'd like to extend/add incoming/input FormGroup like below from my child component:
.group({
username: ["", Validators.required],
email:["", Validators.required],
});
Can anyone suggest me how can i do that?
I have more then 20 fields in my child component. So i don't want to add FormControl one by one. Is there any way to extend JSON like below in existing form-group
{
username: ["", Validators.required],
email:["", Validators.required],
}