Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/142.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有ng repeat的AngularJS相关下拉列表为空_Angularjs - Fatal编程技术网

带有ng repeat的AngularJS相关下拉列表为空

带有ng repeat的AngularJS相关下拉列表为空,angularjs,Angularjs,我试图创建一个依赖下拉列表,但是如果我更改第一个下拉列表,第二个下拉列表总是会留下一个空白 <select class="form-control DB_Control" id="Sector" ng-model="selected_sector" ng-init="selected_sector = initial_selected_sector" ng-options="each.sector for each in data track by each.sector" ng-cha

我试图创建一个依赖下拉列表,但是如果我更改第一个下拉列表,第二个下拉列表总是会留下一个空白

<select class="form-control DB_Control" id="Sector" ng-model="selected_sector" ng-init="selected_sector = initial_selected_sector"  ng-options="each.sector for each in data track by each.sector" ng-change="getSubsector()">

<select class="form-control DB_Control" ng-model='related_subsector3' ng-options="subsector for subsector in sub_sectors track by subsector" >

$scope.getSubsector = function() {
    $scope.related_subsector3 = $scope.sub_sectors[0]
}

$scope.getSubsector=function(){
$scope.related_subsector 3=$scope.sub_sectors[0]
}

更多信息,如果我在函数getSubsector中打印$scope.related_subsector 3的值,则其打印值正确,但未在模板中设置值。

我认为这不起作用。我将尝试创建另一个名为“$scope.getSubSectorChildren()”的函数,该函数将填充第一个函数更改后的第二个下拉列表。这样,您可以使数据填充更灵活,测试/调试也更容易