Skip to content

Can't bind to 'formGroup' since it isn't a known property of 'form' #14288

Closed
@JPtenBerge

Description

@JPtenBerge

I'm submitting a ...

[x] bug report
[ ] feature request
[ ] support request

Current behavior
Simply using the [formGroup] directive when everything has been setup properly results in the error above.

Expected behavior
The formGroup was one of the most basic directives to use when working with Reactive Forms. It tied a form element to the definition of the form (residing in a component). I expect no error. I've used [formGroup] since 2.0.0-RC5 (I think) and the documentation still says it should work like this, but it doesn't.

Minimal reproduction of the problem with instructions

  1. Using @angular/cli, create a new project.
  2. In app.module.ts, change FormsModule to ReactiveFormsModule (two places).
  3. In app.component,html, add this form HTML:
    <form [formGroup]="myForm">
      Naam: <input type="text" formControlName="name"><br>
      Age: <input type="number" formControlName="age">
    
      <button>Save</button>
    </form>
    
  4. app.component.ts:
    import { Component, OnInit } from '@angular/core';
    import { FormBuilder, FormGroup, Validators } from '@angular/forms';
    
    @Component({
    	selector: 'app-root',
    	templateUrl: './app.component.html'
    })
    export class AppComponent implements OnInit {
    	myForm: FormGroup;
    
    	constructor(private fb: FormBuilder) { }
    
    	ngOnInit() {
    		this.myForm = this.fb.group({
    			name: ['', Validators.required],
    			age: ['', Validators.required]
    		});
    	}
    }
    

Running the application will now result in the error: Can't bind to 'formGroup' since it isn't a known property of 'form'.

What is the motivation / use case for changing the behavior?
Basic reactive forms are not working properly anymore.

Please tell us about your environment:
Windows 10 64 bit. Created the project with @angular/cli v1.0.0-beta.30

  • Angular version: 2.3.1 (latest)

  • Browser: all: Chrome 55, Firefox, Internet Explorer 11, Edge 38

  • Language: TypeScript 2.0.3

  • Node (for AoT issues): node --version = 7.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions