我尝试将日期时间值绑定到angular中的kendo-datetimepicker控件,但获取错误date.getTime不是一个函数。日期值不会显示在控件中。
到目前为止,我看到的示例显示了使用新日期。但我正在遍历一个包含日期的服务器对象,并尝试将该日期绑定到控件。我该怎么做?
日期格式为2019-06-23T23:00:00
Html
<tr *ngFor="let c of FundClasses.FundClassColumnNames">
<th [ngClass]="c != 'Buttons1'? 'tableItem bold' : 'tableItem cellbgcolor'"> {{ c }}</th>
<ng-container *ngFor="let fundClass of FundClasses.FundDetailsViewModel let i=index">
<ng-container *ngFor="let f of fundClass['FundClassDetailsViewModel'] | keyvalue">
<td [attr.id]="'f.value.Id'" *ngIf="EditMode[f.value.Id] && c == 'Inception Date'"
class="tableItem">
<kendo-datepicker [format]="'MMM dd, yyyy'" [(ngModel)]="f.value.InceptionDate"
class="form-control form-control-sm">
</kendo-datepicker>{{f.value.InceptionDate}}
</td>
</ng-container>
</tr>发布于 2019-06-25 18:09:03
你可以使用k-ng- ngModel从你的模型中获取数据,而不是使用模型。您可以参考此链接来查看模型CheckOverHere的这种绑定的演示
发布于 2021-07-07 21:10:09
如果您使用的是受控制的datetimepicker,请确保传递给它的值是Date对象。所以你的f.value.InceptionDate应该是new Date("2019-06-23T23:00:00")而不是"2019-06-23T23:00:00"
https://stackoverflow.com/questions/56741352
复制相似问题