【发布时间】:2015-09-11 14:43:06
【问题描述】:
我的 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
});
}
【问题讨论】:
-
有没有想过这个问题?
标签: javascript angularjs autocomplete