Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
105
rated 0 times [  110] [ 5]  / answers: 1 / hits: 6274  / 11 Years ago, sat, january 18, 2014, 12:00:00

I have a select element in my html bound to an ng-model.



Something like this example:



<select data-ng-model=accountType data-ng-options=at.name for at in accountTypes>  </select>


My accountTypes would look like this:



accountTypes:[
{ name:'Individual', value: 1, title: 'Individual Account'},
{ name: 'Joint', value: 2, title: 'Joint Account'}
];


How can I achieve the final markup to look like this once the model is bound:



<option value=1 title=Individual Account>Individual</option>
<option value=2 titleJoint Account>Joint</option>


PS: jQuery hacks appreciated but my ideal solution would something (jQuery, DOM-modification)less.


More From » html

 Answers
6

ngOptions doesn't currently support title. Instead, use a ngRepeat on an options tag, or (harder) extend ngOptions to support your needs.



<select ng-model=accountType>
<option ng-repeat=at in accountTypes value={{ at.value }} title={{ at.title }}></option>
</select>

[#48571] Friday, January 17, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
shaina

Total Points: 161
Total Questions: 99
Total Answers: 108

Location: American Samoa
Member since Fri, Sep 24, 2021
3 Years ago
;