から参照されているng2-dateタイムピッカーを使用しています-
https://www.npmjs.com/package/angular2-datetimepicker
ページ1内にあるページ2に移動し、日付による検索の日付時刻ピッカーでデータを検索した後にのみページ2を取得するとします。そして、私はページ2にいて、ページ2をキャンセルし、ページ1に戻り、日時ピッカーがリセットされます。私は同じ日付をもう一度取得しようとしましたが、無駄になりました(私のコード実装が適切ではない可能性があります)ページが変更されると、日付時刻ピッカーはそれ自体をリセットします。ページを更新するか、コード内の日付変数もリセットされます。
だから私の質問は-ページの変更/更新前と同じ値を設定する方法です。
[オプション]を使用しようとしましたが、役に立ちませんでした-
コード-
transaction.component.html
<div class="form-group " >
<angular2-date-picker
[options]="toDateTransaction"
title="Click to enter To Date and Time"
[(ngModel)]="date1" [settings]="settings1"
[(ngModel)]="toDateTransaction"
formControlName="toDateTransaction"></angular2-date-picker>
</div>
transaction.component.ts
export class TransactionComponent implements OnInit{
date1: Date = new Date();
settings1 = {
bigBanner: true,
timePicker: true,
format: 'yyyy-MM-dd hh:mm',
defaultOpen: false
}
ngOnInit() {
this.toDateTransaction = this.shareData.toDateTransact;
}
searchByDate(data_fromDate, data_toDate,filterDataForSearch) {
this.shareData.toDateTransact = this.dataToDate;
this.toDateTransaction = this.shareData.toDateTransact;
}
}
エラー-
Uncaught (in promise): Error: Template parse errors:
Can't bind to 'options' since it isn't a known property of 'angular2-
date-picker'.
<angular2-date-picker title="Click to enter From Date and Time"
[ERROR ->][options]="fromDateTransaction"
[(ngModel)]="date" [settings]="settings"
"): ng:///MasterSystemModule/TransactionComponent.html@52:84
options
はありませんproperty
その日付選択ツールのドキュメントでは、使用して、
現在、更新時にデータを取得するには、データを保存します
Localstorage