你能不能帮我修改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 回答
只需更新您的jQuery和Angular版本,它应该工作:
http://plnkr.co/edit/pp2Ce9CkEKYLhZtLni6p?p=preview