TypeError: this.form._updateTreeValidity is not a function
Binding the template variable #contactForm
appears to cause a name conflict and blow up the template processor as it tries to turn the attached template variable into an NgForm
on the backend. Everywhere I have seen model driven forms used there is no template variable binding on the form, whereas there is a #tv="ngForm"
utilized in template driven forms. It appears there was a miss on the mixing of the two forms approaches which resulted in the error.
Simply removing it will resolve the issue.
It's been a while, but for me the problem was passing the formGroup to the template instead of referencing it directly.
E.g. this is not working
<ng-template #selectField let-field let-group let-frmName="frmName"> <ng-container [formGroup]="group"> <mat-form-field fxFlex="32" floatLabel="always"> <mat-label>{{field.label}}</mat-label> <mat-select [formControlName]="frmName" [required]="field.required"> <mat-option *ngFor="let option of field.options" [value]="option.value"> {{option.description}} </mat-option> </mat-select> </mat-form-field> </ng-container></ng-template>
If I use directly my formGroup
instance it works just fine.
Hope this helps.
When you incorrectly add to your template formGroup="..."
instead of [formGroup]="..."
you'll also get this error message.