【发布时间】:2016-10-24 12:21:27
【问题描述】:
我想知道我是否必须为自己的组件实现ControlValueAccessor 才能获得与DefaultValueAccessor 相同的行为,或者我可以扩展类吗?
扩展类以模板解析错误结束(是的,组件已经是模块的一部分)。
模块:
@NgModule({
imports: [
BrowserModule,
HttpModule,
FormsModule,
],
declarations: [
AppComponent ,
DatePickerComponent,
],
bootstrap: [ AppComponent ],
})
export class AppModule { }
组件:
export class DatePickerComponent extends DefaultValueAccessor {
错误:
Unhandled Promise rejection: Template parse errors:
'date-picker' is not a known element:
1. If 'date-picker' is an Angular component, then verify that it is part of this module.
2. If 'date-picker' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("
<div class="col-sm-7">
<div class="input-group">
[ERROR ->]<date-picker [name]="beginn" [(ngModel)]="startDate"></date-picker>
</div>
<p id="b"):
【问题讨论】:
标签: angular angular2-components