AngularJS, Populating dependent Combobox

前端 未结 4 1479
鱼传尺愫
鱼传尺愫 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 07:55

    You can add a watcher to the controller like this. You can also remove the empty item when you pick different value of the first drop down list.

    $scope.$watch('currentGroup', function () {
        $scope.currentItems = $scope.currentGroup.Items;
        $scope.currentItem = $scope.currentGroup.Items[0];
    });
    

    Demo

提交回复
热议问题