0

I'm not able to bind time which I'm setting in the controller like this

 $scope.info.startTime="12:10:03";

This is my time picker control in HTML

<span class="input-group">
          <input type="text" class="form-control" datepicker-popup="{{format}}"  tabindex="5"
                 ng-model="info.startTime" placeholder="hh:mm"
                 is-open="datepickerOpened1"
                 close-text="Close"/>
          <span class="input-group-btn">

            <button type="button" class="btn btn-default dropdown-toggle" ng-click="openStartTime($event, 'time')">
                <i class="glyphicon glyphicon-time"></i>
            </button>
                <div dropdown is-open="timepickerOpened1">
              <span class="dropdown-menu" role="menu">
                  <timepicker ng-model="info.startTime"  show-meridian="true"></timepicker>
              </span>
            </div>
          </span>
        </span>

Reference:Angular Bootstrap

1 Answer 1

2

You need to set date object in ng-model instead of string.

Change

$scope.info.startTime="12:10:03";

To

var d = new Date();
d.setHours(12);
d.setMinutes(10);
$scope.info.startTime=d;
Sign up to request clarification or add additional context in comments.

3 Comments

Hours, minutes, seconds and milliseconds can be set in one go: d.setHours(12, 10, 0, 0). ;-)
What if the time picker is inside ng repeat.Will there be any change in the bindings?
No there should not be any change. You just need to set date object.

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.