When using my application, I need to extract the selected optgroup value from a dropdown menu.
Here is the sample code:
HTML:
<select ng-model='theModel' ng-change="display(theModel)" >
<optgroup ng-repeat='group in collection' label="{{group.Name}}">
<option ng-repeat='veh in group.Fields'>{{veh.Name}}</option>
</optgroup>
</select>
Controller:
$scope.display = function(name) {
alert(name); // To obtain the selected value and the optgroup value
}
DESIRED OUTPUT: I want to show the selected optgroup value. For example, if I select Field1 under Collection 1, I should see Collection1.Field1 displayed.