[英]Typeahead using angular-ui
I have created a typeahead using the angular-ui library. 我已经使用angular-ui库创建了typeahead。
My current typeahead html is: 我当前的预输入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">
Basically the typeahead search works ok but when i select the type ahead i want to retrieve all the fields which are attached to the customer record such as surname , address etc. The typeahead gets populated into property called $scope.customers in my controller which is done via an ajax call to the api to get all customers. 基本上,typeahead搜索工作正常,但是当我选择前面的类型时,我想检索附加到客户记录的所有字段,例如姓氏,地址等。typeahead被填充到控制器中的名为$ scope.customers的属性中。通过对api的ajax调用来获得所有客户。
So on selection how can i get all the fields related to the selected customer? 那么在选择时,如何获得与所选客户相关的所有字段?
Cheers 干杯
Change the uib-typeahead attribute: 更改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">
This will set the selected customer to the ng-model selectedCustomer
. 这会将所选客户设置为ng-model
selectedCustomer
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.