私のアプリケーションでは、選択したオプトグループの値を選択ドロップダウンで取得します。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
}
必要な出力: 私はコレクションの1の下にフィールド1を選択した場合、私は私のようにグループと値の参照を保持するためのオプションに値を更新したCollection1.Field1
uが質問に手の込んだことができますか?何が必要なのかはっきりしない。 –
あなたの質問に正しく答えてくれました。 –
今、私の答えを確認してください。 – abhinsit