Although there are similar questions out there, I couldn't find one that addresses my specific need:
- ngRepeat inside option-tag
- ngChange inside select-tag
I am trying to retrieve the index of the selected option. Here is a snippet of my code:
<select data-placeholder="Choose" ng-model="pp.sif" name="myname" ng-change="onChangeSifra()">
<option ng-repeat="item in sif.what track by $index" value="{{item.SIF}}">
{{item.LABEL}}
</option>
</select>
The use of ngClick inside the option-tag does not work on Chrome and IE, so that's not a viable solution. Additionally, using ngOption instead of ngRepeat is not an option due to the nature of the array of objects within sif.what.
Any suggestions?
EDIT: For those suggesting the switch to ngOption, here's why it won't work for me. I'm iterating through something like this:
$scope.sif.what = [
{SIF: 1, LABEL: "label 1", SAVED: "save me 1"},
{SIF: 2, LABEL: "label 2", SAVED: "save me 2"},
{SIF: 3, LABEL: "label 3", SAVED: "save me 3"},
]
Basically, in a combobox, the label is displayed as the label, the "sif" is set as the value, and ngModel represents the value of "sif". However, during ngChange, I require access to the entire object, particularly sif.what(index) or $index.
Thank you.