jeudi 9 septembre 2021

I wanted 'else' case to work only after they uncheck all the feilds,how can i approach?

I have selected 4 checkbox, if i uncheck one checkbox,its going to 'else' condition. But i wanted it to go to else condition only after i unchecked all the feilds. How can i approach this. Here is my code .html

 <div class="form-check" *ngFor="let product of DisplayProductList">
                                    <label class="form-check-label text-break">
                                  <input class="form-check-input" type="checkbox" [value]="product.template_name"
                                  [(ngModel)]="product.isChecked" (change)="changeSelection($event)"> 
                                  <span class="form-check-sign">
                                    <span class="check"></span>
                                  </span>
                                </label>
                                </div>

.ts

 changeSelection(event: any) {
    debugger;
    if (event.target.checked) {
      this.selectedItemsList = this.DisplayProductList.filter((product, index) => {

        if (product.isChecked == true) {
         return product.isChecked
 }
      }
      )
    } else {
      this.selectedItemsList = this.ProductData;
    }

Hope i will get solution here. Thank you




Aucun commentaire:

Enregistrer un commentaire