2016-05-12 51 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

相关问题