How to check is checkbox is checked angular2

前端 未结 2 1734
清酒与你
清酒与你 2020-12-18 09:04

I want to check is checkbox is checked or unchecked in an if and else statement.

Ch         


        
2条回答
  •  -上瘾入骨i
    2020-12-18 09:11

    declare a variable called it filter

    filter: boolean= false;
    

    then use ngModel in html part to access and assign its value.

    
    

    it will call a function filterData() which you can use to do all your functionality

    filter(){
      this.filter = !this.filter;// this will change value of it true and false 
    }
    

    for more checkbox you can use declare more variable like filter1: boolean

提交回复
热议问题