我很难在离子-4上设置默认日期,基本上我已经尝试了以前版本中使用的其他方法,但是有些东西改变了,它们不起作用。
HTML:
<ion-item>
<ion-label position="floating" color="primary">Date</ion-label>
<ion-datetime class="nutri-primary" color="primary" [(ngModel)]="date" display-format="MMM DD, YYYY HH:mm"></ion-datetime>
</ion-item>
在my page.ts文件中:
private date;
ngOnInit(): void {
this.date = moment().toISOString();
}
字段显示时没有默认日期,可以选择日期,并且可以在typescript中正确访问。问题是,当进入页面时,我想显示的默认日期(现在)不在那里。
我的DEPS:
"dependencies": {
"@angular/common": "^7.2.2",
"@angular/core": "^7.2.2",
"@angular/forms": "^7.2.2",
"@angular/http": "^7.2.2",
"@angular/platform-browser": "^7.2.2",
"@angular/platform-browser-dynamic": "^7.2.2",
"@angular/router": "^7.2.2",
"@ionic-native/core": "^5.0.0",
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/sqlite": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic/angular": "^4.0.0",
...