0

저는 UI 부트 스트랩의 입력 헤드를 가지고 있지만 데이터가 수신되면 드롭 다운이 표시되지 않습니다.UIB 유형 헤드가 드롭 다운을 표시하지 않습니다.

    <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> 

$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") 
      }) 
    } 

그리고 HTML은 내가 ng-options에서 같은 sintax를 사용하고는 typehead에 전혀하지만, 잘 작동합니다.

편집 : 나는 마침내 해답을 발견 좋아

답변

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") 
      }) 
    } 
관련 문제