jeudi 6 mai 2021

How to execute multiple functions angular at the same time when a checkbox is ticked

I have a checkbox, that when checked / unchecked runs a function:

        <label class="custom-control custom-checkbox" style="display: block">
          <input type="checkbox" class="custom-control-input" id="parentCheckbox" name="parentCheckbox"
                 [ngModel]="hasAcceptedCheckbox"  (ngModelChange)="oncheckboxAcceptanceChange($event)">
          <span class="custom-control-indicator"></span>
          <span class="custom-control-description">
            <span id="cookiePolicyLabelStart">
              ....
          </span>
        </label>

  get hasAcceptedCheckbox(): boolean {
    return this.hasAcceptedchild1 && this.hasAcceptedchild2 && this.hasAcceptedchild3 
  }


  oncheckboxAcceptanceChange(event) {

      this.Onchild1Acceptance(event);

      this.Onchild2Acceptance(event); 

      this.Onchild3Acceptance(event);
   }

an example of one of the 3 methods I am trying to run

      Onchild1Acceptance(newValue: boolean): void {
            .....
  }

so when i run the above, the oncheckboxAcceptanceChange method only fires each method one at a time per click, Im trying to make them all fire at the same time and I'm having trouble with making it all happen at once.

any ideas?




Aucun commentaire:

Enregistrer un commentaire