Leeuwtje
Leeuwtje

Reputation: 2261

how to show 2 properties in typeahead angular?

I am using the angular bootstrap typeahead:

<input type="text" ng-model="selected" selectState(state.id) typeahead-on-select='onSelect($item, $model, $label)'  typeahead="state.name for state in states | filter:$viewValue | limitTo:8" class="form-control">

At the moment I am displaying the state.name property. Is there a quick way of displaying state.id and state.name together in the input?

plunkr: http://plnkr.co/edit/PVXPUiUmLyi80XkY5F9V?p=preview

Upvotes: 0

Views: 266

Answers (1)

HankScorpio
HankScorpio

Reputation: 3651

Yes there is:

<input type="text" ng-model="selected" selectState(state.id) typeahead-on-select='onSelect($item, $model, $label)'  typeahead="(state.id + ' ' + state.name) for state in states | filter:$viewValue | limitTo:8" class="form-control">

Changed state.name to (state.id + ' ' + state.name)

Upvotes: 1

Related Questions