未捕获错误:模板解析错误,Angular 2?

时间:2017-08-07 13:08:26

标签: angular

尝试启动应用程序时出错:

Uncaught Error: Template parse errors:
Can't bind to 'ngModel' since it isn't a known property of 'md-select'.
1. If 'md-select' is an Angular component and it has 'ngModel' input, then verify that it is part of this module.
2. If 'md-select' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("

我不确定我是否理解问题。但我有导入:

import { BrowserModule } from '@angular/platform-browser';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';

1 个答案:

答案 0 :(得分:2)

您的应用中缺少FormsModule。

  

在app.module.ts中执行以下操作:

import { FormsModule } from '@angular/forms';
// ...
@NgModule({
  imports: [
    // Add FormsModule in your imports[]  
    FormsModule,
    // ...    
  ],