gpt4 book ai didi

javascript - AngularJS angular-ui bootstrap timepicker 作为下拉菜单

转载 作者:行者123 更新时间:2023-11-30 08:47:26 28 4
gpt4 key购买 nike

我喜欢在像日期选择器这样的输入元素中将时间选择器显示为下拉菜单(弹出窗口)。是否有任何简单的方法可以完成此操作,或者是否需要一个完整的新指令?

最佳答案

HTML

<div class="container container-fluid" ng-controller="MainCtrl">
var1={{var1}}
<form class="form-horizontal" novalidate name="form" ng-submit="submit()">
<div class="well">
<div id="date" class="input-append" datetimez ng-model="var1">
<input data-format="hh:mm:ss" type="text" id="input1" name="input1"></input>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
</div>
</div>
</form>

</div>

JS

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
$scope.var1 = '12-07-2013';
});


app.directive('datetimez', function() {
return {
restrict: 'A',
require : 'ngModel',
link: function(scope, element, attrs, ngModelCtrl) {
element.datetimepicker({
language: 'en',
pickDate: false,
}).on('changeDate', function(e) {
ngModelCtrl.$setViewValue(e.date);
scope.$apply();
});
}
};
});

Fiddle Demo

关于javascript - AngularJS angular-ui bootstrap timepicker 作为下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20758484/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com