Angular - Show or Hide based on Dropdown list value

后端 未结 4 1352
小鲜肉
小鲜肉 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:05

    You can add a variable that controls the selected value. For example selectedType, then, use ngIf to hide or show the elements.

    In the .component.ts

      selectedType = 'opentype';
    
      onChange(event) {
        this.selectedType = event.target.value;
      }
    

    In the html

    Application Name is required!

提交回复
热议问题