0

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you !! so much that helped a lot
@masa..could you please help on the below error,i have upgraded the Angular to 1.4.8,but still getting this error.am unable to reproduce it in plunker Uncaught TypeError: Cannot read property 'openCntr' of undefined(anonymous function) @ jquery.ptTimeSelect.js?v=1448900535634:471m.event.dispatch @ jquery-1.11.3.min.js:4r.handle @ jquery-1.11.3.min.js:4..I
TypeError: Cannot read property 'options' of undefined at HTMLInputElement.<anonymous> (localhost:8080/home/common/libs/latest/js/…) at Function.m.extend.each (localhost:8080/home/common/libs/vendor/jquery/1.11.3/…) at m.fn.m.each...jquery file ... at jQuery.fn.ptTimeSelect (localhost:8080/home/common/libs/js/…) at localhost:8080/home/js/common/app.js?v=1448900535634:374:13
Sorry, I would need more info (preferably a plunker) to be able to say what goes wrong in here.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.