简体   繁体   English

带有DateTimePicker的日期选择器

[英]Date Picker with a DateTimePicker

i have a directive for select date in my html 我在我的html中有一个选择日期的指令

JSFIDDLE 的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"
        };
    });

Now i want to insert into this DatePicker insert time slots like this, when i select a slot i return for example $scope.time='00h-12' 现在,我想在此DatePicker中插入这样的时隙,当我选择一个时隙时,例如返回$scope.time='00h-12'

I couldn't find out how to do it. 我不知道该怎么做。

在此处输入图片说明

In your customDatepicker directive, you can update the datepicker directly, for example $.datepicker.dpDiv.append($("#custom-footer").contents().text()); 在您的customDatepicker指令中,您可以直接更新datepicker ,例如$.datepicker.dpDiv.append($("#custom-footer").contents().text()); ; ; see line 21 of the referenced jsfiddle below. 请参阅下面引用的jsfiddle的第21行。

Also, following your convention, I added the custom footer text as a template embedded in a script tag; 另外,按照您的约定,我将自定义页脚文本作为模板嵌入脚本标签中。 see lines 7-10. 参见第7-10行。

Updated fiddle with the solution: http://jsfiddle.net/haroldcampbell/FVfSL/808/ 使用该解决方案更新了小提琴: http : //jsfiddle.net/haroldcampbell/FVfSL/808/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM