0

私はUIブートストラップのタイプヘッドを持っていますが、データが受信されるとドロップダウンは表示されません。UIBタイプヘッドはドロップダウンを表示しません

$scope.obtainUsers = function (valor) { 
     console.log(valor) 

      $http({ 
       method: "POST", 
       url: "http://localhost:3000/obtainUsers", 
       params: {"valor": valor} 
      }).then(function successCallback(response){ 
       console.log(response.data); 

       return response.data; 

      }, function errorCallback(error){ 
       alert("ERROR") 
      }) 
    } 

そしてtypeheadに、私はng-optionsに同じsintaxを使用して、それがうまく動作しますが、無HTML

    <input type="text" ng-model="selectedValue" uib-typeahead="userName as userName.userName for userName in obtainUsers($viewValue)" typeahead-loading="loadingUsers" typeahead-no-results="noResults" class="form-control"> 
        <i ng-show="loadingUsers" class="glyphicon glyphicon-refresh"></i> 
        <div ng-show="noResults"> 
         <i class="glyphicon glyphicon-remove"></i> No Results Found 
        </div> 

編集:私は最終的に答えを見つけて[OK]を

答えて

1

obtainUsersは約束を返さなければなりません。試してみてください:

$scope.obtainUsers = function (valor) { 
    console.log(valor) 

    return $http({ 
... 
0

、私は欠場ああ、もちろん、HTTPはその [::、{userNameのマリア}、{...ペドロのuserName}]のような配列を取得$ HTTPの背後にあるRETURN

HTML:

uib-typeahead="nombreUsuario.nombreUsuario for nombreUsuario in obtenerUsuarios($viewValue)" 

JS:

$scope.obtenerUsuarios = function (valor) { 
     return $http({ 
       method: "POST", 
       url: "http://localhost:3000/obtenerUsuarios", 
       params: {"valor": valor} 
      }).then(function successCallback(response){ 
       return response.data; 
      }, function errorCallback(error){ 
       alert("No se han podido enviar los datos") 
      }) 
    } 
関連する問題