angular - ngFor 中的 Kendo Datepickers
问题描述
我有一个ngFor
循环显示 5 个日期选择器的列表。当用户选择一个值时,我可以看到该let
值正在更新。但是,支持模型永远不会更新。
我app.component.ts
的很简单
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
})
export class AppComponent {
public value: Date = new Date(2000, 2, 10);
public dateValues = [
new Date(2019, 1, 1),
null,
new Date(2019, 3, 1),
null,
new Date(2019, 5, 1)];
}
观点如下:
<div *ngFor="let b of dateValues; let i = index">
<div class="input-group registration-date-time">
<kendo-datepicker class="form-control" [(value)]="b"></kendo-datepicker>
</div>
</div>
<div *ngFor="let b of dateValues">
<div>{{b}}</div>
</div>
<br/>
<kendo-datepicker class="form-control" [(value)]="value"></kendo-datepicker>
VALUE IS: {{value}}
现场演示在这里: https : //stackblitz.com/edit/angular-3pcquq,它还显示了 ngFor 之外的 DatePicker 更新字段。
需要更改哪些内容才能更新外观中的支持模型?
解决方案
这应该修复您的代码:
<div *ngFor="let b of dateValues; let i = index">
<div class="input-group registration-date-time">
<kendo-datepicker class="form-control" [(value)]="dateValues[i]"></kendo-datepicker>
</div>
</div>
推荐阅读
- rest - HERE Map tile API:解码几何
- javascript - 选择通过新音频添加的音频
- reactjs - 在表单标签中保存日期
- android - 获取不同查询的请求函数重载
- git - 我该如何处理这个 Git 警告?“不鼓励在不指定如何协调不同分支的情况下进行拉取”
- c# - c# 在数据库中搜索表单
- pandas - Pandas DataFrame:按空字符串索引排序值
- java - 如何将 TestNG 中的驱动程序传递给第二个测试类?
- javascript - 未在 Embedded Power BI 报告中获取 report.getPages
- php - 使用 nexmo/vonage 与 2 人进行实时语音通话