I've created a component with 2 FormGroups
In component class:
//Forms for Create and Edit nodes
public formCreateCategoryInLevel : FormGroup;
public formCreateCategoryInSubLevel : FormGroup;
this.formCreateCategoryInLevel = this.formBuilder.group({
"categoryNameInLevel":[null,[Validators.required, Validators.maxLength(80)]],
"categoryDescriptionInLevel":[null,[Validators.required, Validators.maxLength(300)]],
});
this.formCreateCategoryInSubLevel = this.formBuilder.group({
"categoryNameInSubLevel":[null,[Validators.required, Validators.maxLength(80)]],
"categoryDescriptionInSubLevel":[null,[Validators.required, Validators.maxLength(300)]],
});
//My submit forms methods:
onSubmitCreateCategoryInLevel(){
//...some code
}
onSubmitCreateCategoryInSubLevel(indexSelected_ofSubParent: number){
//...some code
}
In template:
<form [formGroup]="formCreateCategoryInLevel"
(ngSubmit)="onSubmitCreateCategoryInLevel()">
...
</form>
<form [formGroup]="formCreateCategoryInSubLevel"
(ngSubmit)="formCreateCategoryInSubLevel(1)">
...
</form>
The when I call the first form submit method onSubmitCreateCategoryInLevel(), everything works perfectly, but when I call the second method formCreateCategoryInSubLevel(1) i get an Exception
As if one only one form can be created in a component, is this the case? or what?