Can't bind to 'formgroup' since it isn't a known property of 'form'

Can't bind to 'formgroup' since it isn't a known property of 'form'

Solution:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AppComponent }  from './app.component';

@NgModule({
    imports: [
        BrowserModule,
        FormsModule,
        ReactiveFormsModule
    ],
    declarations: [
        AppComponent
    ],
    bootstrap: [AppComponent]
})

export class AppModule { }

Explanation:

FormGroup in Angular is a selector for directive named FormGroupDirective that is a part of ReactiveFormsModule, and that's the reason why we have to import it. This can be used to bind an already present FormGroup to a DOM element.


πŸ”₯ 179 Views
Mar 18, 2022