Got it working finally. I was having some issues with posted examples, but 
I found one that works with some modifications. Here's the directive:

module App.MyApp {

    var datepickerDirectiveArray = [
        (): ng.IDirective => ({
            restrict: 'A',
            require: 'ngModel',
            link: function (scope, elem, attrs, ngModel: 
ng.INgModelController) { // Had to include type to access $setViewValue.
                var updateModel = function (dateText) {
                    scope.$apply(function () {
                        ngModel.$setViewValue(dateText);
                    });
                };
                var options = {
                    dateFormat: "mm/dd/yy", // Random oddness. Only use 
'yy'. If 'yyyy' is used, the full year will render twice.
                    onSelect: function (dateText) {
                        updateModel(dateText);
                    }
                };

                elem.datepicker(options); // Wire up jQuery-UI datepicker 
with specified options.
            }
        })
    ];

    angular.module("portalAppModule").directive('dtDatePicker', 
datepickerDirectiveArray);
}




On Thursday, December 29, 2016 at 6:57:01 AM UTC-7, William Snell wrote:
>
> I'm trying to get a jQuery-UI datepicker to work in my AngularJS app, but 
> am running into some problems. At first I was using the HTML5 datepicker 
> Chrome uses for inputs of type date. This worked OK, but only in Chrome. I 
> switched over to using the jQuery-UI datepicker, only to have Chrome try to 
> open both datepickers at once. I switched the input type to 'text', which 
> took care of the extra datepicker issue, but when I submit my form for 
> processing, the date value in the input field is null. 
>
> For the best compatibility, I think I need to use an input type of 'text'. 
> Can anyone explain why the value of this field is null when hitting my 
> controller code, but setting the type to 'date' sends the value?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to