내 구성 요소에 DefaultValueAccessor
과 동일한 동작을 얻으려면 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"):
예 이미 등록되었습니다. – CSchulz
@CSchulz 모듈의 코드를 추가 할 수 있습니까? – yurzui
내 질문에 추가되었습니다. – CSchulz