Topic: Looking for TimePicker Example in new version

Mark Boyce free asked 3 years ago

I'm looking for a detailed example of how to use the Timpicker successfully.

The documentation here is not complete as it doesn't show the output of it working properly. The examples found here has what I'm looking for in the Basic Example. But there's no code sample for it. The new version works differently.

What I'm after is the following.

  • Show the timepicker when user clicks on the input field. Input field should not allow user to type manually.
  • Timepicker should bind to a value in the component and be validated.

What I can't figure out is if the value field in the component should be string or date. Can I bind a date and get a date as the response from the timepicker?

Please let me know the right way to use this component.

Mark Boyce free commented 3 years ago

Further investigation revealed that if I set a value to the formcontrol that is tied to the timepicker, even if it's valid (12:00AM), it throws an undefined error and the value is set to undefined. But when I pick the same time using timepicker, it seems to set the exact value to that formcontrol without any problems.

Mark Boyce free commented 3 years ago

Another thing I notice is that when the timepicker opens, it is triggering form submit automatically for some reason. I'm seeing actions from form submission happen when the modal window pops up.

I only have autoClose property set to true in the timepicker. Any idea what could be causing this?

Mark Boyce free answered 3 years ago

I tried as you suggested. But it doesn't seem to work. Here's my code.


<div class="md-form">
<label for="form1">Example label</label>
<mdb-timepicker #timepicker></mdb-timepicker>


selectedTime: "11:24AM"; 
timepickerControl = new FormControl("11:24AM");

And this is the output I'm getting.

enter image description here

And the console error is below.

core.js:6006 ERROR TypeError: Cannot read property 'match' of undefined
at ng-uikit-pro-standard.js:25978
at SafeSubscriber.schedulerFn [as _next] (core.js:25653)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:183)
at (Subscriber.js:122)
at Subscriber._next (Subscriber.js:72)
at (Subscriber.js:49)
at (Subject.js:39)
at EventEmitter_.emit (core.js:25622)
at MdbTimePickerDirective.set value [as value] (ng-uikit-pro-standard.js:26140)
at SafeSubscriber._next (ng-uikit-pro-standard.js:26153)

Mark Boyce free commented 3 years ago

Also, I tried to create a snippet using your tool. But it doesn't show me how to add additional modules to the app module as I don't seem to have access to that. I wanted to add Form modules so I can use the form control. Is there some way I'm supposed to do that?

Arkadiusz Idzikowski staff commented 3 years ago

@Mark Boyce I think the problem is caused be the typo in selectedTime: "11:24AM";. It should be selectedTime = "11:24AM";.

Currently, it's not possible to edit module files in the snippets.

Mark Boyce free commented 3 years ago

Thank you. Fixing the typo solved the value binding. But the fix doesn't seem to work for dynamic properties. Wish I could demonstrate to you with a snippet. Can you send me an email to which I can send a sample project using my mdb pro license?

Arkadiusz Idzikowski staff commented 3 years ago

@Mark Boyce You can send it to

Mark Boyce free commented 3 years ago

Did you get my invite as well as my email?

Arkadiusz Idzikowski staff commented 3 years ago

@Mark Boyce Yes, thank you. The sample code will be of great help in finding the cause of the problem.

I'm afraid there is no workaround for this problem and we will need to fix that in the component internal code. We will update the thread if we find any temporary solution.

Arkadiusz Idzikowski staff answered 3 years ago

There seems to be a bug where the value of the input is not correctly updated on form control change. The toggle button doesn't have type="button attribute, that's why it can incorrectly submit the form on click.

I prepared an example that you can use until these errors are fixed on our end. I added [value] to the timepicker input to resolve the problem with value init. I also added a custom toggle button and (click) method to the input, to toggle component on input click.

In this case, you should always use string as the input data.


<div class="md-form">
  <label for="form1">Example label</label>
  <button (click)="" type="button" class="mdb-timepicker-toggle">
      class="svg-inline--fa fa-clock fa-w-16"
      viewBox="0 0 512 512"
  <mdb-timepicker #timepicker></mdb-timepicker>


  value = '11:24AM';
  timepickerControl = new FormControl('11:24AM');


.mdb-timepicker-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  border-color: transparent;
  background-color: transparent;

  svg {
    height: 1em;

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: MDB4 11.1.0
  • Device: PC
  • Browser: Chrome
  • OS: Any
  • Provided sample code: No
  • Provided link: Yes