admin管理员组文章数量:1429930
HTML:(I have installed ngxMatDatetimePicker for datetime picker.i have set stepminute to every 15 minutes. this will calculate from current minute, but i need set default value should be 00. so if we click up arrow it will add 15,30, 45.. how to set default minute is 00??.. and also input field is taking dd-mm-yyyy hh:mm:ss format, even I gave showseconds to false. actual format should be dd-mm-yyyy hh:mm can you help me?)
<mat-form-field>
<input matInput [ngxMatDatetimePicker]="picker" placeholder="Time Slot" formControlName="time_slot"
[disabled]="disabled">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #picker [showSpinners]="showSpinners" [showSeconds]="showSeconds"
[stepHour]="stepHour" [stepMinute]="stepMinute" [stepSecond]="stepSecond"
[touchUi]="touchUi" [color]="color" [enableMeridian]="enableMeridian" >
</ngx-mat-datetime-picker>
</mat-form-field>
ponent.ts:
public disabled = false;
public showSpinners = true;
public showSeconds = false;
public touchUi = false;
public enableMeridian = false;
public stepMinutes = [0o0, 15, 30, 45];
public stepHour = 1;
public stepMinute = 15;
public stepSecond = 1;
public defaultTime = [new Date().getHours, 0o0 , 0o0] // i have tried like this
public color: ThemePalette = 'primary';
HTML:(I have installed ngxMatDatetimePicker for datetime picker.i have set stepminute to every 15 minutes. this will calculate from current minute, but i need set default value should be 00. so if we click up arrow it will add 15,30, 45.. how to set default minute is 00??.. and also input field is taking dd-mm-yyyy hh:mm:ss format, even I gave showseconds to false. actual format should be dd-mm-yyyy hh:mm can you help me?)
<mat-form-field>
<input matInput [ngxMatDatetimePicker]="picker" placeholder="Time Slot" formControlName="time_slot"
[disabled]="disabled">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #picker [showSpinners]="showSpinners" [showSeconds]="showSeconds"
[stepHour]="stepHour" [stepMinute]="stepMinute" [stepSecond]="stepSecond"
[touchUi]="touchUi" [color]="color" [enableMeridian]="enableMeridian" >
</ngx-mat-datetime-picker>
</mat-form-field>
ponent.ts:
public disabled = false;
public showSpinners = true;
public showSeconds = false;
public touchUi = false;
public enableMeridian = false;
public stepMinutes = [0o0, 15, 30, 45];
public stepHour = 1;
public stepMinute = 15;
public stepSecond = 1;
public defaultTime = [new Date().getHours, 0o0 , 0o0] // i have tried like this
public color: ThemePalette = 'primary';
Share
Improve this question
edited Jun 8, 2020 at 11:50
Rekha
asked Jun 8, 2020 at 11:28
RekhaRekha
4237 silver badges25 bronze badges
1
- hello :) did you find any solution to that ? – toto Commented Aug 19, 2020 at 10:29
1 Answer
Reset to default 3Add defaultTime in the ponent.html
<mat-form-field>
<input matInput [ngxMatDatetimePicker]="picker" placeholder="Time Slot" formControlName="time_slot"
[disabled]="disabled">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #picker [showSpinners]="showSpinners" [showSeconds]="showSeconds"
[stepHour]="stepHour" [stepMinute]="stepMinute" [stepSecond]="stepSecond"
[touchUi]="touchUi" [color]="color" [enableMeridian]="enableMeridian" [defaultTime]="defaultTime">
</ngx-mat-datetime-picker>
</mat-form-field>
In ponent.ts
public disabled = false;
public showSpinners = true;
public showSeconds = false;
public touchUi = false;
public enableMeridian = false;
public stepMinutes = [0o0, 15, 30, 45];
public stepHour = 1;
public stepMinute = 15;
public stepSecond = 1;
public defaultTime = [new Date().getHours(), 0 , 0]
public color: ThemePalette = 'primary';
本文标签: javascriptset default minute in ngxmatdatetimepicker in angularStack Overflow
版权声明:本文标题:javascript - set default minute in ngx-mat-datetime-picker in angular? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745551475a2662962.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论