使用 angular-ui 提前输入

Typeahead using angular-ui

我使用 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">

基本上预输入搜索工作正常,但是当我 select 预输入时,我想检索附加到客户记录的所有字段,例如姓氏、地址等。预输入填充到 属性 在我的控制器中调用了 $scope.customers,这是通过 ajax 调用 api 来获取所有客户来完成的。

那么 selection 我如何获得与 selected 客户相关的所有字段?

干杯

更改 uib-typeahead 属性:

<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