Description
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
- Using
@angular/cli
, create a new project. - In app.module.ts, change
FormsModule
toReactiveFormsModule
(two places). - 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>
- 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