首页 文章

需要Angular js指令用于JQUERY PTTIMESELECT Timepicker插件

提问于
浏览
0

你能不能帮我修改Jquery pttimeselect timepicker插件的角度指令 .

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

Plunker链接:http://tinyurl.com/hr7lker

目前我有如下指令,但收到此错误 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 回答

  • 1

    只需更新您的jQuery和Angular版本,它应该工作:

    <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

相关问题