angular - 如何使用 my-date-picker 填充默认日期
问题描述
我正在使用 my-date-picker 。如何使用默认日期填充日期字段(我从服务中获得的默认日期)。我正在使用以下代码从服务中返回 outOldestDate。我正在尝试将其设置为 onInit 函数中的默认日期。但日期没有得到填充。
<my-date-picker name="outOldestDate" class="form-control required" placeholder="Oldest" [options]="myDatePickerOptions formControlName="outOldestDate"></my-date-picker>
public myDatePickerOptions: IMyDpOptions = {
// other options...
dateFormat: 'yyyy-mm-dd'
};
ngOnInit() {
this.accountReceivableForm = this.formBuilder.group({
outOldestDate: [null, Validators.required]
});
this.getDate();
}
getDate(): void {
//service call happens here
resultArray => {
this.ng4LoadingSpinnerService.hide();
console.log(resultArray);
this.ARHospitalListData = resultArray;
this.outOldestDate = this.ARHospitalListData.dischargeDate.fromDate;
}
}
解决方案
this.outOldestDate = { formatted: this.ARHospitalListData.dischargeDate.fromDate };
添加格式化解决了这个问题
推荐阅读
- python - 如何验证从桌面应用程序中的链接文本按钮打开的网页响应代码
- google-apps-script - 在 Google 应用程序脚本 MailApp.sendEmail 中使用多个 cc 和/或 bcc
- typescript - 泛型类型返回不接受包含相同定义字段的对象
- date - 通过的季度百分比
- javascript - 在 Javascript 或 jquery 中键入功能时进行搜索?
- ios - Swift PHImageManager 照片库图像在选择集合视图单元格后获取 PHImageManagerMaximumSize
- sql - 当表中的记录数是指定限制数的倍数时,如何使用 ref 游标获取集合?
- geometry - 检查圆周运动的边缘
- flutter - 在颤动的警报对话框中显示选定的图像
- php - Symfony 4:使用 CollectionType 时表单不显示输入字段