2つの日付フィールド、開始日は&、終了日は2つ使用するコンポーネントがあります。Angular2 - 反応形式の日付フィールドの設定
デフォルトでは、終了日フィールドが無効になっており、開始日を選択するとその項目が切り替わります。
this.transitionForm = this.fb.group({
effectiveEndDate: [{ value: '', disabled: true }]
.....
});
私はコード内にこの終了日フィールドの値を設定しようとしています。
this.transitionForm.controls['effectiveEndDate'].setValue(this.utils.currentDate());
ユーティリティ機能:
/**
* Returns the current date
*/
currentDate() {
const currentDate = new Date();
const day = currentDate.getDate();
const month = currentDate.getMonth() + 1;
const year = currentDate.getFullYear();
return month + "/" + day + "/" + year;
}
HTML:
<input type="date" class="form-control input-sm" id="effectiveEndDate" name="effectiveEndDate" placeholder="Required" formControlName="effectiveEndDate">
何らかの理由で、フィールドはいえ更新取得されません。
PatchValue
も使用しようとしていて、それも設定していませんでした。
私には何が欠けていますか?
最終的にそこにいました。私のバージョンはPlunkerでも使えました。 – JGFMK