angular 9 Can't bind to 'formGroup' since it isn't a known property of 'form'
See original GitHub issue
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 9.0.6
Node: 12.16.0
OS: darwin x64
Angular: 9.0.6
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.6
@angular-devkit/build-angular 0.900.6
@angular-devkit/build-optimizer 0.900.6
@angular-devkit/build-webpack 0.900.6
@angular-devkit/core 9.0.6
@angular-devkit/schematics 9.0.6
@ngtools/webpack 9.0.6
@schematics/angular 9.0.6
@schematics/update 0.900.6
rxjs 6.5.4
typescript 3.7.5
webpack 4.41.2
import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { LoginRoutingModule } from './login-routing.module';
import { LoginComponent } from './login.component';
@NgModule({
declarations: [LoginComponent],
imports: [LoginRoutingModule, ReactiveFormsModule]
})
export class LoginModule { }
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
loginForm: FormGroup;
constructor(
private fb: FormBuilder
) { }
ngOnInit(): void {
this.loginForm = this.fb.group({
username: ['', Validators.required],
password: ['', Validators.required],
});
}
onSubmit() {
}
}
<form [formGroup]="loginForm" (ngSubmit)="onSubmit()">
<div class="form-group">
<input type="email" class="form-control" formControlName="username" required placeholder="username: name@example.com">
</div>
<div class="form-group">
<input type="password" class="form-control" formControlName="password" required placeholder="password: admin123">
</div>
<button type="submit" [disabled]="!loginForm.valid" class="btn btn-primary btn-block">Login</button>
</form>
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Can't bind to 'formGroup' since it isn't a known property of 'form'
Ok after some digging I found a solution for "Can't bind to 'formGroup' since it isn't a known property of 'form'." import {...
Read more >Fixing Can't bind to 'formGroup' since it isn't a known property ...
Steps to fix Can't bind to formGroup since it isn't a known property of form error in Angular,1. Import FormsModule, ReactiveFormsModule ...
Read more >Can t bind to formGroup since it isn t a known property of form
It is used to bind an existing FormGroup to a DOM element which is the RC5 FIX. You will also need to import...
Read more >Can't bind to 'formGroup' since it isn't a known property of 'div ...
In this video, we will fix cant bind to ' formGroup ' issue. When you start to use formgroup in angular, this is...
Read more >Angular can't bind to 'formgroup' since it isn't a known property ...
... in the template of component and showing following message " can't bind to ' formgroup ' since it isn't a known property...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@VinitTomar The import of
ReactiveFormsModule
should be sufficient@Vaibhav161994 I presume you edited that example to verify this, however your changes are not present in that link (I guess it’s some sort of template)
Anyhow, I can only reproduce if I don’t include
ReactiveFormsModule
in the NgModule that declares the component, but then the error is legitimate. @mzl1988 Is there something specific about your setup, or did some information get lost when you shared the pieces of code? Perhaps you can create a Github repo that showcases the issue.This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.