2016-10-24 10 views
2

내 구성 요소에 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"): 

답변

0

새로운 각도 버전을 사용하면 DefaultValueAccessor을 확장하고 아무런 문제없이 값 접근자를 등록 할 수 있습니다.

1

당신이 당신의 모듈의 지시 배열에 '날짜 피커'를 포함나요?

+0

예 이미 등록되었습니다. – CSchulz

+0

@CSchulz 모듈의 코드를 추가 할 수 있습니까? – yurzui

+0

내 질문에 추가되었습니다. – CSchulz

관련 문제