html - Checkbox with ngfor -


i have component being for-looped. when click 1 (app-product-card), want corresponding checkbox true or checked. how do that? have html

<div class="list-content fluid">     <div class="products-cards" *ngfor="let product of datasource['docs']">         <div class="ui checkbox">             <input class="singlecheckbox" type="checkbox" [checked]="product">             <label hidden></label>         </div>         <app-product-card [product]="product" (click)="select(product)"></app-product-card>     </div> </div> 

you use local reference of child component did below:

<div class="list-content fluid">     <div class="products-cards" *ngfor="let product of datasource['docs']">         <div class="ui checkbox">             <input class="singlecheckbox" type="checkbox" [checked]="appproduct.product===product"> // here need match selected product             <label hidden></label>         </div>         <app-product-card #appproduct [product]="product" (click)="select(product)"></app-product-card>     </div> </div>  app product comp: ts  public product;  select(product){ this.product = product;} 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -