Ulrich Fischer
Ulrich Fischer

Reputation: 173

Display different value than options text in Dropdown

I have a data source which looks like this

$scope.NameList = [
 { id:1, name:'Thomas S.', short:'TS' }, 
 { id:2, name:'Paul F.', short:'PF' },
 { id:3, name:'Kate M.', short:'KM' }
]

I want my DropDown to display the property name as options, bind the id property to a model and display the the property short of the selected item. Is there a way to achieve that with ng-options?

Upvotes: 3

Views: 1136

Answers (1)

hoeni
hoeni

Reputation: 3280

No, because it uses the HTML select component that is not able to distinguish between the displayed text in the dropdown and the shown value.

However you could build an own directive for implementing a similar behaviour, for example with a bootstrap dropdown menu.

Upvotes: 1

Related Questions