【发布时间】:2017-01-25 08:35:10
【问题描述】:
对于我的应用程序,我想在选择下拉列表中获取选定的 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>
控制器:
$scope.display = function(name) {
alert(name); // i want to get the selected value and the optgroup value
}
需要输出: 我想显示选择的 optgroup 值,如果我在 Collection 1 下选择 Field1,我需要 Collection1.Field1
【问题讨论】:
-
你能详细说明这个问题吗?不清楚你需要什么。
-
干杯然后@abhinsit 正确回答了你的问题
-
您现在可以检查我的答案吗?
标签: javascript angularjs select ng-options