>>Hi everybody,
>>
>>Suppose I have the following markup
>>
>>
>> <div class="col-xs-6">
>> <label class="control-label">@Labels.activityEvent:</label>
>> <select class="form-control" ng-model="currentOperatorsNotification.activType"
>> ng-options="t.value as t.text for t in metaData.events"></select>
>> </div>
>>
>>I want to be able to get the currently selected item text into a property. How can I do that with ng-options?
>>
>>Thanks in advance.
>
>Not sure what you mean by 'property' but (guessing) you could use t as the model value and extract anything from that:
<select class="form-control" ng-model="currentEvent"
> ng-options="t as t.text for t in metaData.events"></select>
><div>{{currentEvent.text</div>
But you'd need to watch currentEvent to keep currentOperatorsNotification.activType in sync with currentEvent.value
I implemented that solution yesterday, but one minor problem I found is that in order to set up the initial value correctly I had to find that event in the metaData.events (e.g. I added an initial loop check). Just setting the event's object properties to correct values was not enough.
If it's not broken, fix it until it is.
My Blog