How to display custom label in SELECT dropdown using ng-options.

Skip to first unread message

Ashit Vora

Jul 15, 2013, 9:01:10 AM7/15/13

How can I display custom label in select dropdown.
I have two fields in my object that I was it in select dropdown.

result should be something like...

  <option value="1"> (</option>
  <option value="1"> (</option>
  <option value="1"> (</option>
  <option value="1"> (</option>

Emil Stolarsky

Jul 16, 2013, 9:39:17 AM7/16/13
Hey Ashit,

You'd want to use the ng-options directive to achieve that. It works very similarly to ng-repeat. In your select element, you'd add the directive with the parameters "labelValue for optionValue in objArr" (Note, those are placeholders). Since you need the label to contain multiple properties and for it to be formatted a certain way, you could have 'labelValue' be a call to a function (with the arguments being the obj properties you want to show in the label) that returns a string the way you'd like to be formatted. 
Reply all
Reply to author
0 new messages