AngularJS, Populating dependent Combobox

前端 未结 4 1470
鱼传尺愫
鱼传尺愫 2021-01-03 07:25

What I am trying to achieve is to populate a child combobox with items which depend on a \'parent\' combobox.

To clarify the - or better my - problem, I have created

4条回答
  •  [愿得一人]
    2021-01-03 08:00

    You should refer currentGroup to populate the options inside items combobox:

    
    

    You dont need $scope.currentItems at all. So just update the last 2 lines inside the controller to:

    $scope.currentItem = $scope.currentGroup.Items[0];  
    

    Now to remove the empty option, use super easy and light-weight ng-change:

    
    

    Define the corresponding change handler in the controller:

    $scope.groupChanged = function(){
        $scope.currentItem = $scope.currentGroup.Items[0];
    }
    

提交回复
热议问题