How to add a button in a mat-select option when an option is selected?

Discussão em 'Angular' iniciado por bestfirstsearch, Setembro 23, 2024.

  1. I'm trying to add a url button next to an mat-select option when it is selected. Clicking that button will open a new tab with info related to that option. I don't want all options to have this button when the mat-select is dropped down, just when it is selected.

    I'm having trouble finding a solution for this. Does anyone how I can accomplish this?

    <mat-select [formControl]="formControl" (optionSelected)="onSelected($event)">
    <mat-option></mat-option>
    @for (option of options; track option) {
    <mat-option [value]="option.value">
    {{option.key}}
    <button (click)="openLink()">Open<button> <!-- only want this when it is selected -->
    </mat-option>
    }
    </mat-select>

    Continue reading...

Compartilhe esta Página