Angular ui 时间选择器弹出窗口未显示

Angular ui timepicker pop up not showing up

以下代码未显示弹出时间选择器。知道如何解决吗?

代码:

<ul class="dropdown-menu custom-scroll dropDownLabel custom-width" role="menu" aria-labelledby="btn-append-to-body"
                    ng-show="!sr.timedisplay" 
                >
                    <li role="menuitem">
                        <a href="" ng-click="$event.stopPropagation()">Start Time
                           
       <p class="input-group">
        <input type="text" class="form-control" timepicker-popup ng-model="sr.startTime" is-open="opened" timepicker-options="timeOptions" ng-required="true"/>
         <span class="input-group-btn">
          <button class="btn btn-default" ng-click="sr.getTime('startTime')"><i class="glyphicon glyphicon-time"></i></button>
         </span>
        </p>
                        </a>
                    </li></ul>

没有timepicker-popup,至少官方没有documentation - the question is tagged as ?

但是您可以使用 timepickerdropdown 自己创建一个 :

<span uib-dropdown auto-close="outsideClick">
  <a href uib-dropdown-toggle>
    {{ displayTime }}
  </a>
  <ul class="uib-dropdown-menu">
     <li>
        <uib-timepicker ng-model="mytime" hour-step="hstep" minute-step="mstep" show-meridian="ismeridian"></uib-timepicker>
     </li>
  </ul>
</span>

脚本与 timepicker docs 基本相同,除了用于下拉列表的 displayTime :

$scope.$watch('mytime', function(newValue, oldValue) {
    var hour = $scope.mytime.getHours()-($scope.mytime.getHours() >= 12 ? 12 : 0),
        hour = hour<10 ? '0'+hour : hour,
        minutes = ($scope.mytime.getMinutes()<10 ? '0' :'') + $scope.mytime.getMinutes(), 
        period = $scope.mytime.getHours() >= 12 ? 'PM' : 'AM';
    $scope.displayTime = hour+':'+minutes+' '+period
  })

plnkr -> http://plnkr.co/edit/J4alKogyKuevSGdTkLFQ?p=preview

注意: plnkr 在 0.14.3 中。如果你在 0.14.0 之前使用 Angular UI Bootstrap 那么当然跳过 uib- 前缀并且它会起作用。


带有字形的按钮样式:

<span class="btn btn-default" uib-dropdown auto-close="outsideClick" >
  <a href uib-dropdown-toggle>
    {{ displayTime }} <i class="glyphicon glyphicon-time"></i>
  </a>  
  <ul class="uib-dropdown-menu">
     <li>
        <uib-timepicker ng-model="mytime" hour-step="hstep" minute-step="mstep" show-meridian="ismeridian"></uib-timepicker>
     </li>
  </ul>
</span>

http://plnkr.co/edit/fyC6TfDsrJqsuGCqm11t?p=preview

基于 David 的 sample/input,这是一个在 html 中带有输入组件但没有控制器的示例。我针对 Firefox 和 Chrome 对其进行了测试,效果很好。顺便说一句,我正在使用 bootstrap v3.3.6 和 Angular UI bootstrap v1.3.2.

<div class="row">
    <div class="col-md-2" style="text-align: right">
        <label>Time Picker Popup</label>
    </div>
    <div class="col-md-2">
        <div class="input-group">
            <input type="text" class="form-control">
            <div class="input-group-btn" uib-dropdown auto-close="outsideClick">
                <button type="button" class="btn btn-default dropdown-toggle" uib-dropdown-toggle><i class="glyphicon glyphicon-time"></i></button>
                <ul class="dropdown-menu dropdown-menu-right" uib-dropdown-menu>
                    <li><uib-timepicker ng-model="mytime" hour-step="1" minute-step="15" show-meridian="false"></uib-timepicker>
                </ul>
            </div>
        </div>
    </div>
</div>

这曾经有效:

<uib-timepicker></uib-timepicker>

现在你需要这样做:

<div uib-timepicker></div>