【发布时间】:2018-11-04 15:25:46
【问题描述】:
我正在使用来自 - 的 ng2-date 时间选择器 -
https://www.npmjs.com/package/angular2-datetimepicker
假设我转到位于 page-1 内的 page-2 并且您仅在通过 search-by-date datetime pickers 搜索数据后才获得 page-2 。然后我在第 2 页并取消第 2 页并返回第 1 页,日期时间选择器重置。我试图再次取回相同的日期但无济于事(可能发生我的代码实现不正确)。一旦页面更改,日期时间选择器是否会自行重置。有没有办法在之后取回相同的日期页面刷新或代码中的日期变量也被重置。
所以我的问题是 - 如何将其值设置为与页面更改/刷新之前相同。
我尝试使用 [options] 但无济于事 -
代码-
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
【问题讨论】: