材料设计light mdl-select
问题描述:
我正在尝试在Angular应用中使用mdl-select组件。材料设计light 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/[email protected]:59
答
你的问题是,你是不是导入模块属性,它需要引导你的根app.module.ts
。
从您的自定义组件中取出import { MdlSelectModule } from '@angular-mdl/option'
,并将其移动到app.module.ts
。此外,将MdlSelectModule
添加到您的imports: []
阵列中app.module.ts
您的导入是什么样的?每当我遇到这个问题时,它都是一个导入或引导问题 –
就像这里的指令一样。 https://github.com/mseemann/angular2-mdl-ext/tree/master/src/components/select。我使用'@ angular-mdl/select';'在需要选择的组件中输入{MdlSelectModule}。 – Ciprian
你可以尝试'@ angular-mdl/option';'import {MdlOptionComponent}? –