I have created a Form called compaign
; My purpse is to register Form's inputs data within a FormGroup Object and send it to my backend ! The first thing I have done it ; is that I created a FormGroup
model i used the class CompaignForms
, then i had to instanciate this class
using a local variable called compaignexample
; After that i have created the main FormGroup
object called compaignform
and i had to initialize it with compaignexample
attributes using get
method ! But the problem is in my template becauz i worked with formControl
and ngModel
at the beginning ! So i was urged to delete the directive [(ngModel)]
and i kept only formControlName
, However , the console displays that i have to make a parent component ( [formGroup]
) ! I tried it in vain !! Please how can i fix that problem ! I mentionned my stackblitz demo and it doesnt contain the whole project !! there is a path problem there ! but the only problem which figure out currently is the one above !!
remove this code #compaignForm="ngForm"
from your form tag and add this [formGroup]="compaignexample"
to your form tag.
<form [formGroup]="compaignexample" (ngSubmit)="saveCompaign()"></form>
ngForm
is used when creating Template-driven forms.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.