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

419
Views
la radio de la estera angular comprueba si el valor cambia

¿Hay un evento para un grupo de radio mat en el que podamos detectar si cambia un valor? porque quiero activar un método o una función solo si el valor seleccionado de la radio cambia.

Entonces, por ejemplo, hago clic en el botón A y el valor es 0 y luego hago clic en el botón A nuevamente, entonces debería devolver falso ya que el valor no cambió.

#html

 <mat-radio-group [(ngModel)]="filters" aria-label="Select an option" [disabled]="isLoading" > <mat-radio-button value="1" (change)="onChange($event)" > A </mat-radio-button> <mat-radio-button (change)="onChange($event)" value="2" > B </mat-radio-button> </mat-radio-group>

#tscode

 export class Something { filters: any; onChange(event: MatRadioChange) { console.log('event' , event) if (this.isLoading) { return; } this.table.pageIndex = 0; if (event.value === 2) { this.filters = '2'; this.callAllData(); } else { this.filters = '1'; this.callMyData(); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar el enlace bidireccional [(ngModel)]="binding" para actualizar su variable como tal:

 <mat-radio-group [(ngModel)]="selectedValue"> <mat-radio-button [value]="0">BUTTON A</mat-radio-button> <mat-radio-button [value]="1">BUTTON B</mat-radio-button> </mat-radio-group>

En tu caso sería:

#html:

 <mat-radio-group [(ngModel)]="filters" (change)="onChange()" aria-label="Select an option" [disabled]="isLoading" > <mat-radio-button value="1"> A </mat-radio-button> <mat-radio-button value="2"> B </mat-radio-button> </mat-radio-group>

#mecanografiado:

 export class Something { filters: any; onChange() { console.log('filters' , this.filters) if (this.isLoading) { return; } this.table.pageIndex = 0; if (this.filters === 2) { this.callAllData(); } else { this.callMyData(); } }
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!