Angular Bootstrap Time Picker not Binding time

不打扰是莪最后的温柔 提交于 2019-12-23 05:40:08

问题


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:


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;


来源:https://stackoverflow.com/questions/28018159/angular-bootstrap-time-picker-not-binding-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!