1

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

代码:

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

4

3 回答 3

6

没有这样的东西timepicker-popup,至少在官方文档中没有- 问题被标记为

但是您可以使用timepickerand a自己创建一个dropdown

<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 文档中的脚本基本相同,除了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

于 2015-10-25T17:54:19.367 回答
5

这曾经有效:

<uib-timepicker></uib-timepicker>

现在你需要这样做:

<div uib-timepicker></div>
于 2016-11-01T19:07:28.407 回答
0

基于大卫的示例/输入,这是一个带有 html 输入组件的示例,但没有控制器。我在 Firefox 和 Chrome 上对其进行了测试,效果很好。顺便说一句,我正在使用引导程序 v3.3.6 和 Angular UI 引导程序 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>
于 2016-04-29T14:40:51.180 回答