Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

420
Visualizações
angular mat radio check if value changes

is there an event for a mat radio group where we can detect if a value changes ? cause I wanna trigger a method or a function only if select value from the radio changes.

So for example I click botton A and the value is 0 and then i click button A again then it should return false since the value did not change.

#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 Respostas
Responde à pergunta

0

You can use two-way binding [(ngModel)]="binding" to update your variable as such:

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

In your case, it would be:

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

#typescript:

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda