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);
                });
            };
        }
    };
});
Krishna
  • 1
  • 6

1 Answers1

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

masa
  • 2,762
  • 3
  • 21
  • 32
  • Thank you !! so much that helped a lot – Krishna Dec 08 '15 at 21:57
  • @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 – Krishna Dec 10 '15 at 23:00
  • TypeError: Cannot read property 'options' of undefined at HTMLInputElement. (http://localhost:8080/home/common/libs/latest/js/jquery.ptTimeSelect.js?v=1448900535634:456:60) at Function.m.extend.each (http://localhost:8080/home/common/libs/vendor/jquery/1.11.3/jquery-1.11.3.min.js:2:2975) at m.fn.m.each...jquery file ... at jQuery.fn.ptTimeSelect (http://localhost:8080/home/common/libs/js/jquery.ptTimeSelect.js?v=1448900535634:449:21) at http://localhost:8080/home/js/common/app.js?v=1448900535634:374:13 – Krishna Dec 10 '15 at 23:12
  • Sorry, I would need more info (preferably a plunker) to be able to say what goes wrong in here. – masa Dec 11 '15 at 07:03