简体   繁体   中英

Typeahead using angular-ui

I have created a typeahead using the angular-ui library.

My current typeahead html is:

<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.

So on selection how can i get all the fields related to the selected customer?

Cheers

Change the uib-typeahead attribute:

<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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM