【发布时间】:2015-04-27 18:36:30
【问题描述】:
我正在使用带有 angular js 的 typeahead 并且一切正常,期待一个案例。
假设我搜索了一些东西,比如说test,它显示了两个测试结果,但我没有点击结果,而是点击了我正在输入的文本框或屏幕上的其他任何地方,然后再次输入搜索内容然后搜索不起作用,请求被发送到后端,我得到了响应,但该响应没有在前端显示为搜索结果。
我的代码:
<input type="text" class="form-control " name="search_title" ng-model="formData.search_title" required autocomplete="off" typeahead="state as state.name for state in searchStates($viewValue) | orderBy:name" typeahead-loading="loading" typeahead-min-length="2" typeahead-wait-ms="100" typeahead-on-select='searchSelect($item, $model, $label)'>
$scope.searchStates = function(state){
return $http({
method : 'GET',
url : '/search-state/?q='+state,
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
}).then(function(response,status){
return response.data;
});
}
【问题讨论】: