Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS - ng-options compound text of option

Tags:

angularjs

I have array with object:

[
    ...
    {
        id: 1,
        name: 'Value',
        desc: 'Test'
    }      
    ...  
]

How i can generate option by ng-options with text Value (Test)?

like image 264
Sc0Rp1D Avatar asked Mar 20 '23 06:03

Sc0Rp1D


1 Answers

You could use:

<select
    ng-model="selectedOption"
    ng-options="o.id as o.name + ' (' + o.desc + ')' for o in options">            
</select>

Demo

like image 62
sp00m Avatar answered Mar 29 '23 01:03

sp00m