How to set initial value of mdb-time-picker


Topic: How to set initial value of mdb-time-picker

david@shadowshot.systems pro asked 8 months ago

Expected behavior When a value is specified, the clock starts at that position (eg '07:00' should have the hands on 7 and 00 respectively)

I'm specifying my NgModel as a string. Perhaps I'm using the wrong datatype?

Actual behavior No matter what value is specified in NgModel, the clock always starts at 12:00AM. After using the clock to set the value, it persists.

Resources (screenshots, code snippets etc.)

Html

<mdb-time-picker [buttonLabel]="'Done'" [twelvehour]="true" [darktheme]="false" [label]="'Clock In'" [showClock]="false" [ngModel]="clockIn" (timeChanged)="clockIn_changed($event)"></mdb-time-picker>

TS

private _clockIn = '07:00';

public get clockIn()
{
    return this._clockIn;
}

public set(value) {
    this._clockIn = value;
}

clockIn_changed(e) {
        console.log(e);
 }

Arkadiusz Idzikowski staff commented 8 months ago

You added the default date correctly, it looks like a bug. We will take a closer look at that and fix that as soon as possible.

After picking the date manually, you need to click 'done' button to confirm. Only then the picker value will be updated.


ShadowshotSys pro answered 8 months ago

this solved my problemhttps://mdbootstrap.com/support/angular/not-able-to-set-default-values-to-timepicker/

using writeValue instead of selectedHours


Please insert min. 20 characters.
Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: Angular
  • MDB Version: 8.7.0
  • Device: PC
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No