Populate Dropdown 2 based on Dropdown 1 selection

前端 未结 3 1500
再見小時候
再見小時候 2020-11-30 08:55

I am able to populate 2 dropdowns directly from database. My problem is, the 2nd dropdown values has to be populated based on the 1st dropdown selection. Since i am new to

3条回答
  •  粉色の甜心
    2020-11-30 09:47

    I implemented like following, Hope it helps :)

    Controller code

    var app = angular.module("app",[]);
    app.controller("ctrl",function($scope){
        $scope.key_options = [
        {table:"Table_1",key:"age_flg",key_label:"Age"},
        {table:"Table_1",key:"ethnicity_flg",key_label:"Ethnicity"},
        {table:"Table_2",tab_label:"Table 2",key:"green_flg",key_label:"Green Flag"},
        {table:"Table_2",tab_label:"Table 2",key:"life_flg",key_label:"Life Flag"}
        ];
        $scope.options = [
        {table:"Table_1",tab_label:"Table 1"},
        {table:"Table_2",tab_label:"Table 2"}
        ];
    
    $scope.sel = function(){
        if($scope.key_attr){
        console.log($scope.sel_attr['table']);
        console.log($scope.key_attr['key']);
    };
    }
    });
    

    html code:

    
    
    
    
    
    
    
    
    
    
    
    
    

提交回复
热议问题