Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

240
Vistas
angular prevent user multiple submit

Sometimes user click the save button multiple times and it queues and submit a lot of request and multiple data are created.

How do we prevent it on the front-end that even user click the button multiple times only one request is submitted , anyone knows a clean implementation ? what are the techniques ?

Thanks.

#html code

 <ng-template #editButtons>
      <div class="flex" *ngIf="isEditing">
        <app-page-section-cards-btn
          [btnData]="pageSectionsOptions.btnData.cancel"
          (btnClickEvent)="cancelEdit()"></app-page-section-cards-btn>
        <app-page-section-cards-btn
          [btnData]="pageSectionsOptions.btnData.save"
          (btnClickEvent)="saveDeal()">
      </app-page-section-cards-btn>
      </div>
    </ng-template>

ts code

saveDeal(){
    const payload = {
      "id": 0,
      "name": this.dealDispositionFormFields.dealName,
      "dealType": "Idle Buyout",
      "annualRentProposed": null,
      "annualRentCurrent": null,
      "firmTermRemaining": null,
      "firmTermAdded": null,
      "maxAvailableTerm": null,
      "status": null,
      "capitalContribution": null,
      "parentCloneId": null,
      "accountId": this.currentAccount.accountId,
      "transactionId": this.transactionData.id,
      "dealTypeValues": JSON.stringify(dealTypeValues)
    }
    this.createDispositionDeal(payload);

  }

    createDispositionDeal(payload:any) {
      this._dealService.createDeal(payload)
      .subscribe(
        res=>{
          this._notificationService.showSuccess('Deal was successfully created.');
          if(res.isSuccess){
            this.refreshDealDetailsPage(res.data);
          }  
        },
        err=>{
          console.log('Error creating deal')
        }
      )
    }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

there is a perfect solution using rxjs exhaustMap but You can simply disable your button during the processing of your call and enable it again when the reponse comes

isLoading = false;

saveDeal() {
 this.isLoading = true;
 ...
}


createDispositionDeal(payload:any) {
  this._dealService.createDeal(payload)
  .subscribe(
    res=>{
      this.isLoading = false; // here
      ...
    },
    err=>{
      this.isLoading = false; // here
      ...
    }
  )
}

and add a new input to your component [disabled]="isLoading"

 <app-page-section-cards-btn
      [disabled]="isLoading"
      [btnData]="pageSectionsOptions.btnData.save"
      (btnClickEvent)="saveDeal()">
  </app-page-section-cards-btn>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda