Formbuilder错误DI

时间:2017-05-26 06:30:11

标签: angular angular2-forms

我试图实例化注入FormBuilder,但我不断得到:

EXCEPTION: Uncaught (in promise): Error: DI Error

这就是我的Component的样子:

import { Component, Inject } from '@angular/core';
import { FormBuilder, FormGroup, FormsModule } from '@angular/forms';

@Component({
    selector:'user-new',
    templateUrl:'./user-new.template.html'
})

export class UserNewComponent{

    constructor(@Inject(FormBuilder) _fb: FormBuilder){

    }

}

我的模板中没有与Angular相关的代码,并且是纯HTML。

此外,这是我的app模块:

@NgModule({
  declarations: [
    AppComponent,
    PostsComponent,
    UsersComponent,
    UserNewComponent
  ],
  imports: [
    BrowserModule,
    HttpModule,
    AppRoute,
    FormsModule 
  ],
  providers: [ UserService ],
  bootstrap: [ AppComponent ]
})

0 个答案:

没有答案