1
我在自動填充中遇到錯誤。如何解決自動完成中的錯誤?
JS:
angular.module('MyModule', [])
.controller('myCtrl', function ($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"];
})
.directive('autoComplete', function ($timeout) {
return function (scope, iElement, iAttrs) {
iElement.autocomplete({
source: scope[iAttrs.uiItems],
select: function() {
$timeout(function() {
iElement.trigger('input');
}, 0);
}
});
};
});
HTML:
<div ng-app='MyModule'>
<div ng-controller='myCtrl'>
<input auto-complete ui-items="names" ng-model="selected">
selected = {{selected}}
</div>
</div>
任何幫助,將不勝感激。
嘗試$(iElement).autocomplete(...) –
嘗試更新您的return語句如下 回報{ 限制: 'A', 要求: 'ngModel', 鏈接:功能(範圍,iElement,iAttrs){ iElement.autocomplete({ 來源:姓名, 選擇:函數(){$ 超時(函數(){ iElement.trigger( 'input'); },0); } }); } – CrazyMac
iElement沒有自動完成功能。也許你可以用$(jquery)包裝它 –