Require Angular js directive for JQUERY PTTIMESELECT Timepicker plugin

323 Views Asked by At

Could you please help me in having this angular directive corrected for Jquery pttimeselect timepicker plugin.

http://pttimeselect.sourceforge.net/doc/documentation.html

Plunker link: http://tinyurl.com/hr7lker

Currently i have directive as below ,but getting this error TypeError: Cannot read property 'options' of undefined

app.directive('timePicker', function($parse) {
    return {
        restrict : "C",
        replace : true,
        transclude : false,
        compile : function(element, attrs) {
            var modelAccessor = $parse(attrs.ngModel);

            return function(scope, element, attrs, controller) {
                var processChange = function(i) {
                    var time = i.val();
                    scope.$apply(function(scope) {
                        modelAccessor.assign(scope, time);
                    });
                    scope.$eval(attrs.ngChange);
                };
                element.ptTimeSelect({
                    onClose : processChange
                });
                scope.$watch(modelAccessor, function(val) {
                    element.val(val);
                });
            };
        }
    };
});
1

There are 1 best solutions below

4
masa On

Just update your versions of jQuery and Angular, and it should work:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js"></script>

http://plnkr.co/edit/pp2Ce9CkEKYLhZtLni6p?p=preview