这就是我到目前为止:
JS
.directive('autocompleteDirective', ['$timeout', function (timeout) {
return {
restrict:"A",
templateUrl: currentScriptPath.replace('.js', '.html'),
link: function (scope, el, attr) {
el.autocomplete({
source: scope.model,
select: function () {
timeout(function () {
el.trigger('input');
},0)
}
});
},
scope: {
model: '='
}
};
}]);
HTML
<textarea ng-attr-autocomplete-directive="{{param.autocomplete}}" ng-switch-when="textarea" ng-model="param.value" validator="{{param.validator || 'empty'}}" />
我想要比
更好的东西<textarea ng-attr-autocomplete-directive="{{shouldadd? param.autocomplete:false}}" ng-switch-when="textarea" ng-model="param.value" validator="{{param.validator || 'empty'}}" />