我在 angularjs 中使用带有表单的弹出窗口。我正在使用自动完成器作为-
portfolio.directive('auto', function($timeout) { var names = ["john", "bill", "charlie", "robert", "alban", "oscar", "marie", "celine", "brad", "drew", "rebecca", "michel", "francis", "jean", "paul", "pierre", "nicolas", "alfred", "gerard", "louis", "albert", "edouard", "benoit", "guillaume", "nicolas", "joseph"]; return { restrict : 'A', require : 'ngModel', link : function(scope, iElement, iAttrs) { iElement.autocomplete({ source: names, onSelect: function() { $timeout(function() { iElement.trigger('input'); }, 0); } }); } }; });
它正在工作,但自动完成框在弹出窗口后面打开。 任何人都可以提出解决方案吗?
最佳答案
试试这个
HTML
<div ng-app='MyModule'>
<div ng-controller='DefaultCtrl'>
<input auto ng-model="selected">
selected = {{selected}}
</div>
</div>
脚本
function DefaultCtrl($scope) {
}
angular.module('MyModule', []).directive('auto', function($timeout) {
var names = ["john", "bill", "charlie", "robert", "alban", "oscar", "marie", "celine", "brad", "drew", "rebecca", "michel", "francis", "jean", "paul", "pierre", "nicolas", "alfred", "gerard", "louis", "albert", "edouard", "benoit", "guillaume", "nicolas", "joseph"];
return {
restrict : 'A',
require : 'ngModel',
link : function(scope, iElement, iAttrs) {
iElement.autocomplete({
source: names,
select: function() {
$timeout(function() {
iElement.trigger('input');
}, 0);
}
});
}
};
});
关于javascript - Angularjs 自动完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23692928/