我已经编写了自动完成代码,其中ng-change我从数据库中获取数据并以列表的形式显示自动完成内容。 点击列表中的数据后,我想使用ng-model在输入框中显示该数据,但我无法做到这一点。
以下是我的HTML代码:
<div class="input-group">
<input type="text" class="form-control dropdown-toggle" data-toggle="dropdown" placeholder="add question list" ng-model="qList" aria-describedby="basic-addon2" ng-change="fnAutocompleteQList(qList)">
<div class="dropdown-menu menu-width">
<ul ng-repeat="value in aAutocompleteQList">
<li ng-click="fnfnAutoQList(qList)">{{value.quesList.quesListName}}</li>
</ul>
</div>
<span class="input-group-addon btn-primary textColor" style="cursor:pointer" id="basic-addon2" ng-click="fnAddQuestionList(questionList)">add question list</span>
</div>
以下是我的控制器代码
$scope.fnAutocompleteQList = function(qList) {
var oGetQListPromise = searchBoxService.fnGetQuestionsList(qList);
oGetQListPromise.then(function(response) {
$scope.aAutocompleteQList = response;
});
};
$scope.fnAutoQList = function(qListName) {
$scope.qList = qListName;
};