Angularjs 在angular中使用typeahead的问题

Angularjs 在angular中使用typeahead的问题,angularjs,typeahead,Angularjs,Typeahead,我正在使用typeahead和angular js,一切正常,只需一个案例 假设我搜索了某个东西,比如说test,它显示了两个测试结果,但我没有单击结果,而是单击了我正在键入的文本框或屏幕上的其他任何地方,然后再次,如果我键入搜索内容,则搜索不起作用,请求被发送到后端,我得到了响应,但该响应没有显示在前端作为搜索结果 我的代码: <input type="text" class="form-control " name="search_title" ng-model="formData.

我正在使用typeahead和angular js,一切正常,只需一个案例

假设我搜索了某个东西,比如说
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;
                });

        }
  <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.6.0.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.1/ui-bootstrap-tpls.min.js"></script>

$scope.searchStates=函数(状态){
返回$http({
方法:“GET”,
url:“/search state/?q=”+state,
标题:{'Content-Type':'application/x-www-form-urlencoded'},
}).然后(功能(响应、状态){
返回响应数据;
});
}

当我更改
ui引导tpls的版本时,我的问题得到了解决。之前我使用的是版本
0.12.1
,但当我将其更改为
ui-bootstrap-tpls-0.6.0.js
时,一切正常。所以这个问题可能是因为版本错误

使用这个

 <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;
                });

        }
  <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.6.0.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.1/ui-bootstrap-tpls.min.js"></script>

而不是

 <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;
                });

        }
  <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.6.0.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.1/ui-bootstrap-tpls.min.js"></script>