angular - 将日期绑定到 Angular7 中的 formControlname 输入
问题描述
我是角度的新手。我有一个 type 的输入date
。如何将日期绑定到此输入?
<input type="date" class="form-control" formControlName="startDateInput">
我尝试了以下但没有奏效:
this.createForm.patchValue({
startDateInput:this.resourceData['period'].start,
});
请帮忙
解决方案
对于日期类型输入,您需要转换日期
this.createForm.patchValue({
startDateInput: (new Date()).toISOString().substring(0,10),
});
推荐阅读
- python-3.x - 双击运行脚本时“从 PIL 导入图像”出错
- java - 无法在 Android 动态功能模块中运行检测测试?
- css - 自定义 CSS 到 rmarkdown 块以更改图形的宽度
- ruby - 使用 Ruby bot.rb:4:in 的高音机器人
': main:Object (NameError) 的未定义局部变量或方法 `twitter' - java - 使用 JENA 创建模型
- javascript - 警报处于活动状态时如何专注于选项卡?
- java - Java Spring可以在运行时添加或删除@Component吗?
- c++ - main 中 line 的等效语句是什么?
- c# - Telerik 下拉列表未正确填充
- java - 如何从哪个 JAR 中找到类加载器正在尝试加载特定类?