我使用材料日期选择器:
<mat-form-field>
<input
matInput
[required]="fieldDefinition.required"
[matDatepicker]="dateDocumentStart"
[(ngModel)]="fieldDefinition.fieldvalue"
(focus)="dateDocumentStart.open()"
/>
<mat-datepicker-toggle matSuffix [for]="dateDocumentStart"></mat-datepicker-toggle>
<mat-datepicker #dateDocumentStart></mat-datepicker>
</mat-form-field>
如您所见,我使用[(ngModel)]="fieldDefinition.fieldvalue"
申请日期。
CCD_ 2具有字符串值"0";1997年5月12日";。如何将其转换为特定格式的日期类型?
我已经尝试应用自定义管道:
[(ngModel)]="fieldDefinition.fieldvalue | mycustompipe"
使用管道是一种好方法。
您可以使用Angular的DatePipe,而不是使用自定义管道。
有一个format
参数自定义。