gpt4 book ai didi

javascript - 如何解决自动完成错误?

转载 作者:行者123 更新时间:2023-11-28 04:45:08 25 4
gpt4 key购买 nike

我在自动完成中遇到错误。

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>

我收到如下屏幕截图所示的错误: enter image description here

如有任何帮助,我们将不胜感激。

最佳答案

这是可能对您有帮助的工作示例

    <div ng-app='MyModule'>
<div ng-controller='DefaultCtrl'>
<input complete ng-model="selected">
selected = {{selected}}
</div>
</div>

angular.module('MyModule', []).directive('complete', function($timeout) {
var names = ["john", "James", "Raj"];

return function(scope, iElement, iAttrs) {
iElement.autocomplete({
source: names,
select: function() {
$timeout(function() {
iElement.trigger('input');
}, 0);
}
});
};
});

关于javascript - 如何解决自动完成错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43446501/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com