I am trying to created nested form group in Angular6.
serviceItemForm: FormGroup;
apiForm : FormGroup;
this.serviceItemForm = this.fb.group({
'name': new FormControl('', Validators.required),
'description': new FormControl('', Validators.required),
'categoryIds': new FormControl([], Validators.required),
'tags': [],
'status': '',
'orderFormType': new FormControl([], Validators.required),
'orderFormKey': new FormControl([], Validators.required),
'workflow': [],
'orderFormAction': new FormControl('', Validators.required),
'customUI': new FormControl(''),
'api': this.fb.group({
'apiurl': new FormControl(''),
'apimethod': new FormControl(''),
'headers': this.fb.array([]),
'payload': '',
}),
'userGroup': []
});
this.apiForm = this.serviceItemForm.get('api');
Here this.apiForm is giving error like Type 'AbstractControl' is not assignable to type 'FormGroup'. Property 'controls' is missing in type 'AbstractControl'. In VSCode.
Please help how can I use nested form-group in angular-6