Mercer
Mercer

Reputation: 9986

Date Picker with a DateTimePicker

i have a directive for select date in my 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"
        };
    });

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'

I couldn't find out how to do it.

enter image description here

Upvotes: 0

Views: 489

Answers (1)

haroldcampbell
haroldcampbell

Reputation: 1542

In your customDatepicker directive, you can update the datepicker directly, for example $.datepicker.dpDiv.append($("#custom-footer").contents().text());; see line 21 of the referenced jsfiddle below.

Also, following your convention, I added the custom footer text as a template embedded in a script tag; see lines 7-10.

Updated fiddle with the solution: http://jsfiddle.net/haroldcampbell/FVfSL/808/

Upvotes: 1

Related Questions