Search code examples
angulartimepickerngx-bootstrap

NGX Bootstrap Timepicker Set Value Programmatically


I am using NGX-Bootstrap Timepicker. I want to be able to set the time values programatically.

If I have something like:

<timepicker [(ngModel)]="mytime"></timepicker>

and try to set the time values with something like:

mytime: Date = new Date();
this.mytime.setHours(0);
this.mytime.setMinutes(0);

it does not work. Does anybody have any other suggestions? Stackblitz


Solution

  • set 'mytime' like this :

    const time = new Date();
    time.setHours(14);
    time.setMinutes(0);
    
    this.mytime = time;