2016-05-12 36 views
0

我使用angular-ui庫創建了一個typeahead。使用angular-ui的Typeahead

我現在的預輸入HTML是:

<input name="customers" id="customers" type="text" placeholder="enter a customer" ng-model="selectedCustomer" uib-typeahead="customer.firstName for customer in customers | filter: $viewValue | limitTo:8" class="form-control" typeahead-editable="false"> 

基本上預輸入搜索工作正常,但是當我選擇類型提前我想檢索其連接到客戶記錄,如姓氏的所有字段,地址等。typeahead被填充到我的控制器中名爲$ scope.customers的屬性中,通過ajax調用api來獲取所有客戶。

所以在選擇我怎麼能得到所有與選定的客戶相關的領域?

乾杯

+0

你在問如何知道什麼時候觸發了typeahead或如何做ajax調用?我想我錯過了這個問題。 – Paarth

+0

不,我想知道當我在前面選擇選項時,有一個客戶記錄已用於填充前面的字符,但我只顯示名字。基本上選擇,我想得到其他屬性,如姓等。希望有道理 – tjhack

+0

「讓他們」在哪裏? – Paarth

回答

0

更改UIB-預輸入屬性:

<input name="customers" id="customers" type="text" placeholder="enter a customer" ng-model="selectedCustomer" uib-typeahead="customer as customer.firstName for customer in customers | filter: $viewValue | limitTo:8" class="form-control" typeahead-editable="false"> 

這將所選擇的客戶設置了NG-模型selectedCustomer