Angular - Show or Hide based on Dropdown list value

后端 未结 4 1347
小鲜肉
小鲜肉 2020-12-18 11:33

I want my Dropdown list to show/hide Div based on the value selected

I have a dropdown list and several Div in my angular project as shown in the code



        
4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-18 12:13

    Here I've used ngModel in the dropdown so, that you can get the value which you've selected from the dropdown.

    and in Ts file, you need to declare one variable called optionValue like this:

    `optionValue`;
    

    and now you can use ngIf for show/hide Divs.

    Div1

    
                        
                        
                        
                            Application Name is required! 
                      

    Div2

    
                  
                  
                

提交回复
热议问题