question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

angular 9 Can't bind to 'formGroup' since it isn't a known property of 'form'

See original GitHub issue

image


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

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:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
JoostKcommented, Mar 16, 2020

@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.

0reactions
angular-automatic-lock-bot[bot]commented, Apr 17, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found