Angular Bootstrap Time Picker没有绑定时间

时间:2015-01-19 04:54:32

标签: javascript angularjs datetimepicker timepicker

我无法绑定我在控制器中设置的时间,如此

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

这是我在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>

参考:Angular Bootstrap

1 个答案:

答案 0 :(得分:2)

您需要在ng-model中设置日期对象而不是字符串。

更改

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

var d = new Date();
d.setHours(12);
d.setMinutes(10);
$scope.info.startTime=d;