Angular4.X 报错: Can't bind to 'ngModel' since it isn't a known property of 'input'

来源:互联网 发布:上杉升 知乎 编辑:程序博客网 时间:2024/05/17 11:35

使用angular4时,应用angular指令,如ngModel时,发生如题的错误

原因: 未导入执行指令所需的文件

解决方法: 在app.module.ts文件中导入FormsModule文件,如下所示:

@NgModule({  declarations: [    AppComponent,    Product1Component,    Product2Component,    ErrorComponent  ],  imports: [    BrowserModule,    AppRoutingModule,    FormsModule  ],  providers: [    ProductService,  ],  bootstrap: [AppComponent]})export class AppModule { }

阅读全文
0 0
原创粉丝点击