Binding a mat-select to an onOpen event

Discussão em 'Angular' iniciado por Giovanni Raziq, Março 12, 2025.

  1. I'm trying to bind a mat-select to a function which will call java and get the data that has to be shown as options.

    However the (onOpen) event doesn't works , to be more accurate the function bound to it is never called.

    Does anyone had an issue like this one ?

    Here is my code :

    <mat-form-field>
    <mat-select placeholder="Select Year of the Report" (onOpen)="getData(0)">
    <mat-option *ngFor="let year of this.years">
    {{year}}
    </mat-option>
    </mat-select>
    </mat-form-field>


    Here is the function getData:

    getData(ref: number) {
    console.log('it Works !');
    this.recommendationService.getRecommendationFilters(ref).subscribe((data: any[]) => {
    this.years = data;
    console.log(data.toString())
    });
    }


    Thank You !

    Continue reading...

Compartilhe esta Página