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

518
Views
¿Cómo evitar cambiar MatTab hasta la confirmación?

Quiero detener el cambio de MatTab hasta que se dé una confirmación. He usado MatDialog para confirmación. El problema es que, antes de hacer clic en "Sí", la pestaña ya está cambiada.

Por ejemplo, desde la pestaña de ingresos , hago clic en la pestaña de ajuste . Y antes de cambiar a esa pestaña, primero necesito mostrar la ventana emergente . Pero recibo la ventana emergente después de moverme a la pestaña de ajuste .

ª imagen que muestra la ventana emergente

plantilla de componente:

 <mat-tab-group (click)="tabClick($event)"> <mat-tab *ngFor="let tab of tabs; let index = index" [label]="tab"> <app-spread></app-spread </mat-tab> </mat-tab-group>

componente ts (método de onClick):

 tabClick(clickEvent: any) { if (clickEvent.target.innerText != 'First') { this.confirm(); } } public async confirm() { const dialogRef = this.dialog.open(ConfirmationDialogComponent, { maxHeight: '200px', maxWidth: '767px', width: '360px', disableClose: true, data: { title: 'Confirmation Message', content: 'There are valid statements that are not Final. Set the statements as Final?' } }); const res = dialogRef.afterClosed().subscribe(result => { if (result === 1) { //TODO need to change the tab } else { //TODO no need to change the tab } }); }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Hace algún tiempo simulo un "mat-tab" en este SO

Me imagino que puedes usar esto con solo cambiar la función.

 <mat-tab-group #tabgroup style="margin-bottom:5px;" animationDuration="0" mat-align-tabs="start" (selectedIndexChange)="change(tabgroup,$event)"> ... </mat-tab-group>

Y el cambio de función:

 change(tab:any,index:number) { if (tab.selectedIndex!=this.indexOld){ const dialogRef = this.dialog.open(....) const res = dialogRef.afterClosed().subscribe(result => { if (result === 1) { this.index=index; } else { tab.selectedIndex=this.indexOld; } }); } else { this.index=index; } }

Vea el stackblitz -en el stackblitz simplemente uso el diálogo de confirmación-

over 4 years ago · Santiago Trujillo 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!