Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
angular previene el envío múltiple del usuario

A veces, el usuario hace clic en el botón Guardar varias veces y se pone en cola y envía una gran cantidad de solicitudes y se crean múltiples datos.

¿Cómo evitamos en el front-end que incluso el usuario haga clic en el botón varias veces, solo se envía una solicitud, alguien conoce una implementación limpia? cuales son las tecnicas

Gracias.

#código HTML

 <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>

código ts

 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 answers
Answer question

0

hay una solución perfecta usando rxjs exhaustMap pero simplemente puede deshabilitar su botón durante el procesamiento de su llamada y habilitarlo nuevamente cuando llegue la respuesta

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

y agregue una nueva entrada a su componente [deshabilitado]="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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!