我在输入日期类型时遇到问题。我想绑定(bind)来自组件的数据。这是我的领域:
<div class="col-md-6">
<label for="dateOfReport">Data zgłoszenia błędu:</label>
<input type="date" formControlName="dateOfReport" id="dateOfReport" class="form-control" [value]="report.dateOfReport | date:'dd.MM.yyyy'"> {{report.dateOfReport | date:'dd.MM.yyyy'}}
</div>
以下是变量 dateOfReport 的外观:
new Date().toJSON().slice(0, 10)
我哪里失败了? {{ .. }} 显示了正确的日期,但我的字段不将其视为默认日期。
最佳答案
使用响应式表单时,不应将数据直接绑定(bind)到控件,而应使用 FormGroup 的 setValue() 或 patchValue()。
关于javascript - Angular 5 将日期绑定(bind)到字段( react 形式),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49976356/