ANGULAR 8 @ViewChild options {static: false} causes Can't bind to 'formGroup' since it isn't a known property of 'form'.ngtsc(-998002) in HTML

21 Views Asked by At

Out of the gate, I'm already importing reactive Forms Module.

Here's the problem:

in my .ts file I have the following code:

 @ViewChild('MySuperCoolForm', null) MySuperCoolForm: NgForm;

and there's not a problem with the HTML

 <form id="mysupercoolform" ngForm #MySuperCoolForm [formGroup]="mySuperCoolForm"
    (ngSubmit)="submitForm(mySuperCoolForm, $event)">

BUT

When I change the .ts code to this since null throws an error for @ViewChild

 @ViewChild('MySuperCoolForm', {static: false}) MySuperCoolForm: NgForm;

It creates an ERROR in the HTML like so

[formGroup]="mySuperCoolForm" - Can't bind to 'formGroup' since it isn't a known property of 'form'.ngtsc(-998002)
app.component.ts(39, 1): Error occurs in the template of component AppComponent.
No quick fixes available

Why does this happen and how can I get rid of it... once and for all.

This occurs in Angular 8.2.12 through Angular 14.12.2

0

There are 0 best solutions below