與我的應用程序,我想要在選擇下拉列表中選擇optgroup值。如何在Angularjs中獲取選定的optgroup值?
下面是代碼
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>
Controlelr:
$scope.display = function(name) {
alert(name); // i want to get the selected value and the optgroup value
}
輸出所需: 我想顯示所選OPTGROUP值,如果我下收集1選擇場1,我需要Collection1.Field1
u能闡述這個問題嗎?你不清楚你需要什麼。 –
歡呼然後@abhinsit已正確回答你的問題 –
你能檢查我的答案嗎? – abhinsit