为什么格式' HH:mm'不在此DatePipe中工作?

时间:2018-05-13 18:28:24

标签: angular angular5

我正在尝试在Date字段中显示input对象并仅显示分钟

<mat-form-field>
  <input matInput type="time" placeholder="Choose a time" 
       [(ngModel)]="appointmentTime"
       [ngModel]="appointmentTime  | date:'HH:mm'"/>
</mat-form-field>

但是,时间没有正确显示 - 实际上根本没有显示:

enter image description here

在课堂上,appointmentTimeappointmentDate被初始化为

public appointmentDate = new Date();
public appointmentTime = new Date();

1 个答案:

答案 0 :(得分:-1)

 <input matInput type="time" placeholder="Choose a time" 
       [ngModel]="appointmentTime  | date:'HH:mm'"/>