gpt4 book ai didi

javascript - 带有 DateTimePicker 的日期选择器

转载 作者:行者123 更新时间:2023-12-03 11:15:02 26 4
gpt4 key购买 nike

我有一个在 html 中选择日期的指令

JSFIDDLE

angular
.module('App',['ui.date'])
.directive('customDatepicker',function($compile){
return {
replace:true,
templateUrl:'custom-datepicker.html',
scope: {
ngModel: '=',
dateOptions: '='
},
link: function($scope, $element, $attrs, $controller){
var $button = $element.find('button');
var $input = $element.find('input');
$button.on('click',function(){
if($input.is(':focus')){
$input.trigger('blur');
} else {
$input.trigger('focus');
}
});
}
};
})
.controller('myController',function($scope){
$scope.birthDate = '2013-07-23';
$scope.dateOptions = {
minDate: -20,
maxDate: "+1M +10D"
};
});

现在我想插入到这个 DatePicker 中,像这样插入时间段,当我选择一个时间段时,我返回例如 $scope.time='00h-12'

我不知道该怎么做。

enter image description here

最佳答案

customDatepicker 指令中,您可以直接更新 datepicker,例如 $.datepicker.dpDiv.append($("#custom-footer").contents().text());;请参阅下面引用的 jsfiddle 的第 21 行。

此外,按照您的约定,我添加了自定义页脚文本作为嵌入脚本标记中的模板;请参阅第 7-10 行。

更新了解决方案:http://jsfiddle.net/haroldcampbell/FVfSL/808/

关于javascript - 带有 DateTimePicker 的日期选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27381714/

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