Sc0Rp1D
Sc0Rp1D

Reputation: 53

AngularJS - ng-options compound text of option

I have array with object:

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

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

Upvotes: 4

Views: 1326

Answers (1)

sp00m
sp00m

Reputation: 48837

You could use:

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

Demo

Upvotes: 7

Related Questions