Kann nicht an 'formGroup' gebunden werden, da es keine bekannte Eigenschaft von 'form' ist

DIE SITUATION

Bitte hilfe! Ich versuche, in meiner Angular2-App eine sehr einfache Form zu erstellen, aber egal, was nie funktioniert.

ANGULAR VERSION:

Angular 2.0.0 Rc5

DER FEHLER

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

DER CODE

Die Aussicht

<form [formGroup]="newTaskForm" (submit)="createNewTask()">

    <div class="form-group">
        <label for="name">Name</label>
        <input type="text" name="name" required>
    </div>

     <button type="submit" class="btn btn-default">Submit</button>

</form>

Der Controller

import { Component } from '@angular/core';
import { FormGroup, FormControl, Validators, FormBuilder }  from '@angular/forms';
import {FormsModule,ReactiveFormsModule} from '@angular/forms';
import { Task } from './task';

@Component({
    selector: 'task-add',
    templateUrl: 'app/task-add.component.html'

})


export class TaskAddComponent {

    newTaskForm: FormGroup;

    constructor(fb: FormBuilder) 
    {
        this.newTaskForm = fb.group({
            name: ["", Validators.required]
        });
    }

    createNewTask()
    {
        console.log(this.newTaskForm.value)
    }

}

The ngModule:

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule }   from '@angular/forms';

import { routing }        from './app.routing';
import { AppComponent }  from './app.component';
import { TaskService } from './task.service'


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


export class AppModule { }

DIE FRAGE

Warum erhalte ich diesen Fehler?

Habe ich etwas verpasst?

Antworten auf die Frage(26)

Ihre Antwort auf die Frage