在下拉列表中選擇我試圖創建動態地改變angularJS下拉列表動態地改變在角JS
angulars.js在angulars.js
var option1Options = ["Class","Category","Option","Question","Group"];
var option2Options = [["Group","ProductModel"],
["Class","ProductModel"],
["Class","Group","ProductModel"],
["Group","ProductModel"],
["ProductModel"]];
$scope.myCtrl= function()
{
$scope.options1 = option1Options;
$scope.options2 = [];
$scope.getOptions2 = function(){
var key = $scope.options1.indexOf($scope.child);
$scope.options2 = option2Options[2];
};
}
page.html中
<div id="CreateChild" ng-controller="myCtrl">
<select ng-model="child" ng-options="option for option in options1" ng-change="getOptions2()">
</select>
<select ng-model="parent" ng-options="option for option in options2">
</select>
</div>
我無法獲得第一個下拉列表數組的索引。 鍵值的值被指定爲-1,而選項2被指定爲未定義。 任何一個可以幫我這個
有一些錯別字在代碼中的錯誤......你能創造一個plunkr或jsbin與您的代碼? (例子...你用數組數組來定義option20Options,並且在函數上,你嘗試獲得option20options [2]並且不存在) –