This is not the usual module-related. Because I'm using Angular v16, standalone component, no module is required.
TS
import { FormBuilder, FormGroup, FormControl, Validators, FormsModule } from '@angular/forms';
@Component({
selector: 'app-x',
standalone: true,
imports: [CommonModule, FormsModule, ReactiveFormsModule], // same err with or without FormsModule, ReactiveFormsModule
templateUrl: './x.component.html',
styleUrls: ['./x.component.scss']
})
export class XComonponent
{
public fg1?: FormGroup;
// rest of the code
}
HTML
<form [formGroup]="fg1">formGroup is highlighted as error</form>
This component is generated with --standalone
switch in a legacy Angular project still using @NgModule
in app.module.ts
.