gpt4 book ai didi

javascript - 自动完成文本框未触发所选值

转载 作者:行者123 更新时间:2023-11-30 00:27:04 25 4
gpt4 key购买 nike

我的 AngularJs 应用程序中的自动完成文本框有问题。当我按任意键获得自动完成建议时,我的建议显示在文本框中,所选值显示在文本框中。当我尝试在 html 页面上通过它的 ng-model 显示值时,它只显示我输入的字符以获得自动完成建议,而不是建议值。

谢谢!!!

这是我的 HTML 代码:

<input type="text" id="tags" data-ng-model="placeselected"  data-ng-keyup="complete()"/>
<br />{{placeselected}}

这是我的js:

$scope.complete = function() {
$scope.availablePlaces = [];
$http({
method : 'GET',
url : 'http://localhost:8080/orion-orbit/newclue/cities/ '+ $scope.cityselect.cityCode + '/clueAnswers'
}).success(function(data, status, headers,config) {
$scope.getPlaces=data;
}).error(function(data, status, headers,config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
angular .forEach($scope.getPlaces,function(value) {
if (value.getPlaces !=' ') {
$scope.availablePlaces.push(value.ans);
}
});


$("#tags").autocomplete({
source : $scope.availablePlaces
});
}

最佳答案

不使用 $scope 来检索文本框的值,而是使用 document.getElementById("id").value

var pickup_location = document.getElementById("pickup_location").value;

希望这对您有所帮助!

关于javascript - 自动完成文本框未触发所选值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31042780/

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