4
我已創建使用AngularJS 2個下拉菜單和附加數據。我想要在第一次下拉時發生更改時更改第二個下拉值。AngularJS下拉值通過控制器改變在其中動態
我創建example,但是當我改變第一個下拉的價值;第二個下拉值不會改變。
我已創建使用AngularJS 2個下拉菜單和附加數據。我想要在第一次下拉時發生更改時更改第二個下拉值。AngularJS下拉值通過控制器改變在其中動態
我創建example,但是當我改變第一個下拉的價值;第二個下拉值不會改變。
更新HTML:
<div ng-controller="exerciseTypeCtrl">
<ul data-role="listview" data-inset="true" >
<li>
<select id="exerciseSuperCategory" data-role="listview" ng-options="catagory as catagory.text for catagory in catagories.cast " ng-model="itemsuper" ng-change="changeData()">
</select>
</li>
</ul>
<ul data-role="listview" data-inset="true">
<li>
<select data-role="listview" ng-options="type as type.text for type in types.cast " ng-model="item1" ng-change="update()">
</select>
</li>
</ul>
更新控制器:
myApp.controller('exerciseTypeCtrl',function($scope,indoors,outdoors,setNulls, catagories){
$scope.catagories = catagories;
$scope.types = setNulls;
$scope.changeData = function() {
//console.log($scope.itemsuper);
if($scope.itemsuper.text == "Indoor") {
$scope.types = indoors;
} else if($scope.itemsuper.text == "Outdoor") {
$scope.types = outdoors;
} else {
$scope.types = setNulls;
}
}
});
感謝您的答覆是,我需要 感謝您的關注正確的方法 – Blu
這是我的榮幸 –