0

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])
         }
       });

enter image description here

1 Answer 1

2

use the [(ngModel)] with the checked attribute

  <input type = "checkbox" [(ngModel)]="cutType.checked" (click)="selectCutype('single',cutType.id)"  id="cutType{{cutType.attribute_value}}"  (change)="changeCheckbox(i)" >
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.