2017-10-26 10 views
0

5つの入力フィールドを含む各繰り返しフォーム要素に先読みがあり、結果を選択して入力フィールドに入力するとすべて正常に動作しますしかし、このdoen'tアップデートモデル(ソース)AngularJS UIB TypeAheadはフォームを作成するオブジェクトですが、バインドしません。

先行入力:

<input type="search" 
             ng-model="product" 
             ng-model-options="{ getterSetter: true }" 
             typeahead-editable="true" 
             typeahead-click-open 
             typeahead-loading="product_Loading" 
             typeahead-input-formatter="inputFormatter($model)" 
             typeahead-min-length="0" 
             typeahead-select-on-exact="true" 
             typeahead-no-results="noResults" 
             typeahead-popup-template-url="/app/directives/typeaheadDefaultTemplate.html" 
             typeahead-popup-template-new="products" 
             autocomplete="off" 
             placeholder="Select product" 
             uib-typeahead="tyh as tyh.name for tyh in typeahead($viewValue, 'products')" 
             class="form-control no-border-right"> 

選択された要素の受信者:

<input name="qty" type="number" ng-model="product.qty" class="qty form-control text-right" value="1"> 
<input name="price" type="number" ng-model="product.price" class="price form-control text-right" placeholder="0.00"> 
<input name="total" value="0.00" disabled type="number" class="total form-control text-right"> 
+0

ここでモデル(ソース)を更新することはどういう意味ですか? – roshan

答えて

0

第3の入力は、nが必要gモデルの属性。

先読みでは、ng-modelは検索クエリを参照します。製品オブジェクトを更新して他の入力に流したい場合は、選択またはフォーカスのいずれかをプログラムで実行する必要があります。お使いの先行入力で

、productSearchModelにモデルを更新し、その後、

typeahead-on-select="onSelect($item, $model, $label, $event); productSearchModel = '';" 

は、ユーザーがオプションを選択したときに発生します、あなたのコントローラ

$scope.onSelect = function (item, model, label, event) { 
    product = model; 
}; 

にこのようなものを追加し、次の属性を追加。

関連する問題