简体   繁体   中英

Angularjs typeahead display array of objects

Is it possible to have a typeahead with an array of objects? Example of the array

Edit: My current code only filters through the name object, and i want it to be able to filter through all the object such that, when i enter the postal code into the searchbox, it will display both the name and postal

 <input type="text" ng-model="selected" uib-typeahead="cname for cname in all | filter:$viewValue:onlyMatch| limitTo:5">

The example would be like this : Expected result

You need it as

  <input type="text" ng-model="selected" typeahead="state.NAME for state in POSTALCODES | filter:$viewValue | limitTo:8" class="form-control">

DEMO

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