【发布时间】:2018-05-14 14:50:31
【问题描述】:
我正在尝试在 input 字段中显示 Date 对象并且只显示分钟
<mat-form-field>
<input matInput type="time" placeholder="Choose a time"
[(ngModel)]="appointmentTime"
[ngModel]="appointmentTime | date:'HH:mm'"/>
</mat-form-field>
但是,时间没有正确显示 - 事实上根本没有:
在类中,appointmentTime和appointmentDate被初始化为
public appointmentDate = new Date();
public appointmentTime = new Date();
【问题讨论】:
-
您是否将管道注册为提供者? ngModel 中是否缺少圆括号?