2017-09-30 16 views
1

私はuib-typeaheadで入力テキストを使用してビューを持っています。 入力テキストはフォームにあります。Angularjsと先頭、どのように取り除く[オブジェクトオブジェクト]

ビューをロードするとき、入力テキストには「[オブジェクトオブジェクト]」が約5秒前に表示されてから、リモートサーバーからロードされたデータが入力されます。 リモートサーバーからロードするデータの後に、すべてがokと表示されます。

サーバーからのデータがビューに完全にロードされる前に、この[オブジェクトオブジェクト]が入力テキストにならないようにする方法はありますか?

私はng-cloakを試しましたが、効果はありません。

//マークアップ

<div class="col-sm-9 col-lg-9" id="scrollable-dropdown-menu"> 
    <script type="text/ng-template" id="templatePac.html"> 
      <div class="col-sm-12"> 
       <a href> 
       <span ng-bind-html="match.model.nome | uibTypeaheadHighlight:query"></span> 
       <span> - CPF:</span> 
       <span ng-bind-html="match.model.cpf || 'sem cpf'"></span> 
       </a> 
      </div> 
    </script> 
    <input type="text" ng-model="paciente" required 
    uib-typeahead="item as item.nome for item in getPacientesByName($viewValue)" 
    ng-model-options="{ updateOn: 'default blur', debounce: {'default': 500, 'blur': 0}}" 
    typeahead-editable="false" typeahead-select-on-exact="true" query="query" typeahead-wait-ms="300" typeahead-loading="loadingLocationsPac" typeahead-template-url="templatePac.html" typeahead-no-results="noResultsPac" class="form-control"> 
    <div> 
     <i ng-show="loadingLocationsPac" class="glyphicon glyphicon-refresh"></i> 
     <div ng-show="noResultsPac"> 
     <i class="glyphicon glyphicon-remove"></i> Sem resultados 
     </div> 
    </div> 
</div> 

// JSコントローラ

angular.module('clinang').controller('menuPacientesEvolAtendAddController', function($scope,$state,$http) { 
$scope.paciente={primeiro_atendimento:{prescricao_adotada:{medicamentos:[]}}}; 
... 
... 

$scope.getPacientesByName=function(val){ 
       return $http.get(urlBase+'/configuracao',{params:val}).then((response)=>{ 
        return response.data 
       }, (erro)=>{ 
         console.log(erro); 
       }) 
     } 

    } 
+0

それはあなたがあなたのビューがレンダリングされる前にデータを取得するように決意のデータを取得することで、すべてのことが可能です –

+0

>選択オプションと使用NG-オプションを試してみてください。それが動作するかどうかを確認します。あなたが達成したいと思っているデザインの種類を教えてください。ブートストラップを使っていますか? – DragonKnight

+0

@ Molik Miahこれは他の解決策がない場合に試すオプションです –

答えて

1

あなたは、入力中に先行入力値に応じて、フィールド、 "ノーム" を持っているので、先行入力$ scope.paciente初期値を修正することができますそれを正しく解析できますか?例:

$scope.paciente={nome: "", primeiro_atendimento:{prescricao_adotada:{medicamentos:[]}}}; 
+0

ありがとう、私はそれを解決しました –

関連する問題