简体   繁体   中英

Angular 2 - input type checkbox not getting checked

i Am getting the value check in console but the checkbox is not showing checked.

the code and console is given below

  <input type = "checkbox" (click)="selectCutype('single',cutType.id)"  id="cutType{{cutType.attribute_value}}"  (change)="changeCheckbox(i)" >
        {{cutType.attribute_value}}


 this.array = self.fifthSector.attribute_value_id.split(',');

 console.log('array',this.array)this.array.forEach((elem1, index) => {elem1;
       console.log(elem1)
      res[0].cut_type_sub.forEach((elem2, index) => {elem2;
        console.log(elem2.id)
         if(elem1 == elem2.id)
         {
          //--If elem1 equal elem2
          this.fish_cuttype[index].checked = !this.fish_cuttype[index].checked;
           console.log('Done',elem1 == elem2.id,this.fish_cuttype[index])
         }
       });

在此处输入图片说明

[(ngModel)]checked属性一起使用

  <input type = "checkbox" [(ngModel)]="cutType.checked" (click)="selectCutype('single',cutType.id)"  id="cutType{{cutType.attribute_value}}"  (change)="changeCheckbox(i)" >

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM