lundi 19 mars 2018

Angular 2 : select all checkboxes when clicking on a button outside that div

my task is to select all the checkboxes(get it checked),also get the id of each checkboxes, the code i have used id given below

the div which clicking in outside that of div where checkbox is placed

Html

<div class="col-sm-5 text-right right-actions">
    <a class="select-all" (click)="showallDeleteCheckbox($event)">Select All</a>
</div>
............
..........
 <div *ngIf = "shown"><input  type="checkbox" id=""  class="del-all"></div>
............
.............

.ts

  private confirmedOrder: Observable<any>;
..............
..............
self.confirmedOrder = self.storeService.getConfirmedOrder(self.shopId);
   self.confirmedOrder.subscribe((res:any) => {
   self.confirmed_array_length = res.length;
..............
..............
    howallDeleteCheckbox(ev){
  var self = this;
  self.shown = true;
  console.log('orderlength',self.confirmed_array_length);
  for (var i = 0; i < self.confirmed_array_length; i++) {
    self.confirmedOrder[i].selected = self.selectedAll;
    console.log("im here", self.confirmedOrder[i].selected);
  }


}
.............

The function to perform is delete all selected




Aucun commentaire:

Enregistrer un commentaire