RooksStrife
RooksStrife

Reputation: 1747

Can you link ng-options values together?

Forgive the terminology, but can you link ng-options values together?

This is what I have:

<select class="form-control" id="field_cusPro" 
       name="cusPro" ng-model="rentalAgreement.customerProfile" 
       ng-options="cusPro as cusPro.Name for cusPro in cuspros track by cusPro.id">
 <option value=""></option>
</select>

Is there away to do ng-options="cusPro as cusPro.Name and cusPro.id for cusPro in cuspros track by cusPro.id.

That way the options would be like this:

       Name1 ID1, Name2 ID2  etc...

Instead of just

       Name1, Name2, etc...

Upvotes: 0

Views: 27

Answers (1)

show-me-the-code
show-me-the-code

Reputation: 1553

Yes, you could do this:

<select class="form-control" id="field_cusPro" name="cusPro" ng-model="rentalAgreement.customerProfile" ng-options="cusPro as cusPro.Name+' ('+cusPro.id+')' for cusPro in cuspros track by cusPro.id">
 <option value=""></option>

Upvotes: 1

Related Questions