0
我正在嘗試使用純角度構建自動完成功能,但不幸的是UI有點難以處理。我開始使用jQuery UI進行構建。Angular JS和jQuery UI自動完成功能
然後,我遇到了一個小提琴 http://jsfiddle.net/sebmade/swfjT/light/
<div ng-app='MyModule'>
<div ng-controller='DefaultCtrl'>
<input auto-complete ui-items="names" ng-model="selected">
selected = {{selected}}
</div>
</div>
function DefaultCtrl($scope) {
$scope.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"];
}
angular.module('MyModule', []).directive('autoComplete', function($timeout) {
return function(scope, iElement, iAttrs) {
iElement.autocomplete({
source: scope[iAttrs.uiItems],
select: function() {
$timeout(function() {
iElement.trigger('input');
}, 0);
}
});
};
});
我想顯示的選項用戶輸入3個有效字符之後。
感謝, ANKIT塔納
你好,非常感謝。這工作。 :)我不知道的選項。 – 2015-03-31 07:59:56
這是適當的解決方案:) – 2015-05-28 07:40:44