【发布时间】:2014-08-01 13:41:24
【问题描述】:
如何在尚未准备好 <select> 的指令中“激活”jQuery(element).scombobox()。
如需了解更多详情,请参阅http://plnkr.co/edit
这是html:
<div tu-combobox="" ng-model="comboboxvalue" options="combobox.options"></div>
我有这个指令:
.directive('tuCombobox', function($compile) {
return {
restrict: 'A',
replace: true,
require: 'ngModel',
scope: {
feature: '=',
options: '=',
tudisabled: '='
},
template: '<select ng-disabled="tudisabled" ng-options="option.value as option.text for option in options"></select>',
link: function(scope, element, attributes, ngModel) {
// this doesn't work because the template isn't yet rendered
//element.scombobox();
// but using this i get a bunch of errors $rootScope:inprogress
scope.$watch('ngModel', function(){
element.scombobox();
});
}
};
})
为什么这么难实现?
【问题讨论】:
标签: jquery angularjs jquery-plugins angularjs-directive