我正在尝试在Angular应用程序中使用mdl-select组件。
<form [formGroup]="form">
<mdl-select formControlName="personId">
<mdl-option *ngFor="let p of people" [value]="p.id">{{p.name}}</mdl-option>
</mdl-select>
</form>
我使用此处的说明安装:https://github.com/mseemann/angular2-mdl-ext/tree/master/src/components/select
获取此控制台错误:
Unhandled Promise rejection: Template parse errors:
Can't bind to 'value' since it isn't a known property of 'mdl-option'.
1. If 'mdl-option' is an Angular component and it has 'value' input, then verify that it is part of this module.
2. If 'mdl-option' 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. ("tiple="true" placeholder="Select users">
<mdl-option mdl-ripple *ngFor="let hero of heroes" [ERROR ->][value]="hero.name">{{hero.name}}</mdl-option>
</mdl-select>
"): ng:///AppModule/NewEventComponent.html@19:59
答案 0 :(得分:0)
您的问题是您没有导入模块属性,因为它需要在您的根app.module.ts
中进行自举。
从您的自定义组件中取出import { MdlSelectModule } from '@angular-mdl/option'
,然后将其移至app.module.ts
。另外,将MdlSelectModule
添加到imports: []
app.module.ts
数组中