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

时间:2015-12-08 18:39:42

标签: javascript angularjs angularjs-directive timepicker jquery-ui-timepicker

请你帮我修改Jquery pttimeselect timepicker插件的角度指令。

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

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

目前我有如下指令,但收到此错误 TypeError:无法读取未定义的属性“选项”

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 个答案:

答案 0 :(得分: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