【发布时间】:2019-05-09 10:26:10
【问题描述】:
我正在设置 primeNG 日历,想知道如何在编辑时显示保存的日期。
<p-calendar name="startDate" [(ngModel)]="classPrg.startDate"> </p-calendar>
<p-calendar name="endDate" [(ngModel)]="classPrg.endDate"></p-calendar>
ngOnInit() {
this.classPrg = this.classPrgStore.state.entry.data;
if (!this.classPrg) {
let id: string = this.activedRoute.snapshot.params['id'];
if (await this.classPrgStore.loadClassPrg(id).toPromise()) {
this.classPrg = this.classPrgStore.state.entry.data;
this.classPrg.startDate = new Date(this.classPrg.startDate);
this.classPrg.endDate = new Date(this.classPrg.endDate);
}
}
}
【问题讨论】:
-
你能展示一下你做出承诺的代码吗?
-
async ngOnInit() { this.classPrg = this.classPrgStore.state.entry.data; if (!this.classPrg) { let id: string = this.activedRoute.snapshot.params['id']; if (await this.classPrgStore.loadClassPrg(id).toPromise()) { this.classPrg = this.classPrgStore.state.entry.data; this.classPrg.startDate = new Date(this.classPrg.startDate); this.classPrg.endDate = new Date(this.classPrg.endDate); }}}