コンポーネントのプロパティが認識されないという問題が発生しました。 私のコンポーネントです: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がターゲットとして定義されています。
助けを借りてありがとうございます。
HTMLファイルを表示します。問題はHTMLから来ています –
エラーはテンプレートにあります。投稿できますか? –
あなたの '@Component selector'は' date-control'と言っています。 'date-input'はどこにありますか? –