2017-11-20 14 views
1

コンポーネントのプロパティが認識されないという問題が発生しました。 私のコンポーネントです:Typescript:既知のプロパティでないため、間にバインドできません

import { PrecisionDate } from '../../domain/precision-date'; 
import { Component, Input } from '@angular/core'; 
import { FormControl } from '@angular/forms'; 

import { DatePrecisionType } from '../../domain/date-precision.type'; 
import { ValueRange } from '../../domain/value-range'; 

@Component({ 
    selector: 'date-control', 
    templateUrl: './date-control.component.html', 
    styleUrls: ['./date-control.component.css'], 
}) 
export class DateControlComponent { 
    @Input() precision: DatePrecisionType; 
    @Input() dateRange: ValueRange<Date>; 
    @Input() formControlToUse: FormControl; 

    constructor() {} 

    get between(): ValueRange<PrecisionDate> { 
    return { 
     min: this.dateRange ? new PrecisionDate(this.dateRange.min) : null, 
     max: this.dateRange ? new PrecisionDate(this.dateRange.max) : null, 
    } 
    } 
} 

そして、これがスローエラーです:

Uncaught Error: Template parse errors: 
Can't bind to 'between' since it isn't a known property of 'date-input'. 
1. If 'date-input' is an Angular component and it has 'between' input, then verify that it is part of this module. 
2. If 'date-input' 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. ("<date-input [ERROR ->][between]="between" [precision]="precision" [formControl]="formControlToUse" > </date-input> "): ng:///UiControlsLibraryModule/[email protected]:15 

私はゲッターとセッターのみES5からサポートされていることを知っています。しかし、私のtsconfig.jsonではes5がターゲットとして定義されています。

助けを借りてありがとうございます。

+0

HTMLファイルを表示します。問題はHTMLから来ています –

+0

エラーはテンプレートにあります。投稿できますか? –

+0

あなたの '@Component selector'は' date-control'と言っています。 'date-input'はどこにありますか? –

答えて

3

エラーはあなたのhtmlテンプレートから来ています。あなたのコンポーネントに定義されていない@Inputを使用しようとしているようです。

date-inputコンポーネントには、@Input() betweenを追加するか、htmlから[between]="..."を削除する必要があります。

編集。 date-inputがコンポーネントであるかどうかを確認するか、date-controldate-input :)の間違っているかどうかを確認してください。

編集2. 3つ目のエラーを見てください。

3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("<date-input [ERROR ->][between]="between" [precision]="precision" [formControl]="formControlToUse" > </date-input> "): ng:///UiControlsLibraryModule/[email protected]:15 

スクロールしてビットこれは、エラーが発生したポインタ(この記号[ERROR ->]を探してください)があり、これは私が角愛する理由の一つであり、彼らはほとんどの(間違っているものを指摘することができますケースの場合):)。

編集3.私は忘れていることを忘れて@Inputは、コンポーネントだけでなく、@Directiveの入力の一部となります。

+1

お返事ありがとうございました。その間、私は「@指令」を宣言することを忘れてしまったことが判明しました。今それは動作します!あなたの助けをありがとうございました:)他人を助けるかもしれないので、あなたの投稿を回答としてマークします。 – dave0688

+0

Ach、そうですね、それは '@指令 'でもいいです、私は答えを修正する必要があります:) –

+0

それは私を夢中にしてくれました。 – dave0688

関連する問題