Angular 6材质-如何从matDatepicker获取日期和时间? [英] Angular 6 material - how to get date and time from matDatepicker?
问题描述
我的html中有这段代码:
I have this piece of code in my html:
<mat-form-field>
<input matInput [matDatepicker]="myDatepicker" placeholder="Choose a date" [(ngModel)]="model.value" name="value">
<mat-datepicker-toggle matSuffix [for]="myDatepicker"></mat-datepicker-toggle>
<mat-datepicker #myDatepicker></mat-datepicker>
</mat-form-field>
通过这种方式,我可以使用以下格式获取日期:YYY-MM-DDThh:mm:ss:millisZ
.
使用matDatepicker我可以选择日期,但我也需要在选择日期后再选择时间.
是否可以使用matDatepicker 仅来获得此结果?
谢谢
With this i'm able to get date with this format: YYY-MM-DDThh:mm:ss:millisZ
.
Using matDatepicker i'm able to select the date but i need after the date selection to select the time too.
Is possible to achieve this result using matDatepicker ONLY?
Thanks
推荐答案
否,到目前为止,无法从matDatePicker
中选择time
.关于此功能, github 上仍然存在一个未解决的问题.
No, as of now, it is not possible to choose time
from matDatePicker
. There is still an open issue on github regarding this feature.
问题线程摘要:
或者,您可以使用以下任一选项将dateTimePicker
用于您的项目.
Alternatively you can use one of the following to have dateTimePicker
for your project.
-
MaterialTimeControl -具有角度材质,CDK和Flex布局的材质设计
MaterialTimeControl - Material Design with Angular Material, CDK, and Flex Layouts
amazing-time-picker -不是使用Angular Material构建的,但是与其兼容
amazing-time-picker - Not built with Angular Material, but built to be compatible with it
date-time-picker -并非完全是Material Design,但用CDK构建的
date-time-picker - Not fully Material Design, but built with the CDK
这篇关于Angular 6材质-如何从matDatepicker获取日期和时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!