Krishna
Krishna

Reputation: 1

Require Angular js directive for JQUERY PTTIMESELECT Timepicker plugin

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);
                });
            };
        }
    };
});

Upvotes: 0

Views: 325

Answers (1)

masa
masa

Reputation: 2820

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

Upvotes: 1

Related Questions