0

我正在使用 jquery,引导多选下拉菜单。我想在其他正常(单选)下拉列表(城市)的 selectionChange 事件上填充多选下拉列表(talukas)。我无法弄清楚为什么在控制器的初始加载时会填充多选下拉菜单,以及为什么不会在其他下拉菜单的选择更改时填充。你能帮我么。谢谢你。

场景 - 1 => 这很好用

 <div ng-controller="tempController" ng-init="initializeController()" ng-cloak>
         <select id="multiSelect" name="multiSelect" multiselect=""
           multiple="" ng-model="selectedTalukas" ng-options="option.talukaId as 
           option.label for option in talukas"></select>
</div>



 // .js


$scope.selectedTalukas = [];
     $scope.initializeController = function () {            
                            $scope.talukas = [
                              { talukaId: 1, label: 'Taluka1' },
                              { talukaId: 2, label: 'Taluka2' },
                              { talukaId: 3, label: 'Taluka3' }
                            ]
        }

场景 - 2 => 这不能正常工作 - 为什么

 <select id="city" class="form-control select2" name="ddlCity" ng-model="c" ng-options="c as c.name for c in city | orderBy:'name'"
ng-change="selectedCityChange(c)" >  
</select>

 <select id="multiSelect" name="multiSelect" multiselect=""
   multiple="" ng-model="selectedTalukas" ng-options="option.talukaId as 
   option.label for option in talukas"></select>



 $scope.selectedCityChange = function (selectedValue) {
                if (selectedValue !== undefined) {
                    $scope.selectedCity = selectedValue;
                    $scope.selectedCityId = selectedValue.cityId;
                    $scope.ajaxPost(selectedValue.cityId,
                        '/api/Taluka/getTalukasForSelectedCity',
                        $scope.selectedCityChangeComplete,
                        $scope.selectedCityChangeError);
                }
            };

            $scope.selectedCityChangeComplete = function (response) {               
                $scope.talukas = response.data.talukaMasters;          

            }
4

0 回答 0