AngularJS, Populating dependent Combobox

前端 未结 4 1382
鱼传尺愫
鱼传尺愫 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:54

    There is other solution to this kind of issues. That is to broadcast.

    Do brodcast after you got the data. In this example data came from Ajax call.

    $http.get('/SampleProgram/get_all_users').success(function(rsList){
           $scope.users =  rsList;
           $scope.$broadcast('I got all the users');
        });
    

    There should be listeners who always keeps their ears up for your broadcast message.

    $scope.$on('I got all the users', function () {
            alert("Hey All the users are here already let's make another ajax call with those users");
        })
    

提交回复
热议问题