角度引导时间选取器不绑定时间

Angular Bootstrap Time Picker not Binding time

本文关键字:绑定 定时间 选取 时间      更新时间:2023-09-26

我无法像这样绑定我在控制器中设置的时间

 $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>

参考:角度自举

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

改变

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

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