2

I Am Using ui.bootstrap.timepicker for creating and updating data via user Interaction.

The Timepicker is working well for creating data but it's not binding to the ng-model.

Here is a sample JSON array of the data passed to the Timepicker:

{
   "sort":1,
   "name":"Store Timings",
   "_id":"55b78a8658d3060e004fe9f2",
   "delivery":[
      {
         "open":"10:30",
         "close":"20:00",
         "leadTime":"45",
         "interval":"15",
         "message":"Accepting delivery orders",
         "_id":"55b78a8658d3060e004fe9f3",
         "isOpen":true
      }
   ],
   "pickup":[
      {
         "open":"09:30",
         "close":"20:30",
         "leadTime":"30",
         "interval":"15",
         "message":"Accepting takeot orders",
         "_id":"55b78a8658d3060e004fe9f4",
         "isOpen":true
      }
   ],
   "store":[
      {
         "open":"9:30 AM",
         "close":"10:30 PM",
         "message":"We are Open!",
         "_id":"55b78a8658d3060e004fe9f5",
         "isOpen":true
      }
   ],
   "isOnlineOrderOpen":true
}

As per the Above code I tried to render ng-value in to the Timepicker

Here is the HTML code:

<timepicker ng-model="sunday.store[0].open" hour-step="1" minute-step="15" show-meridian="true" ></timepicker>

<timepicker ng-model="sunday.store[0].close" hour-step="1" minute-step="15" show-meridian="true" ></timepicker>

This is showing that the Timepicker as Blank (I was expecting the values):- blank Timepicker

1 Answer 1

3

The Timepicker is expecting you to pass in a Date object, not a string.

From the Timepicker documentation

ng-model: The Date object that provides the time state.

I'm using MomentJS to format my date from a string to a Date object.

See the MomentJS parse documentation

You can transform your times back to a string if required using the same library.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.