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

170
Visualizações
Angular Opening a Dialog when an option is selected

In my app, I have a mat-form-field with a mat- option. I want a dialog to open when I select an element from the mat-option. Here is my code. Right now, when I select an element, nothing happens. What should I do?

HTML:

                <ng-container matColumnDef="Order">
                    <th mat-header-cell *matHeaderCellDef width="10%"> Sipariş No </th>
                    <td mat-cell *matCellDef="let row; let i = index">
                        <span *ngIf="EditIndex != i">{{row.Order?.Subject}}</span>
                        <mat-form-field floatLabel="never" *ngIf="EditIndex == i" class="w-100-p" style="min-width: 100px !important;">
                            <mat-select [(ngModel)]="row.Order" required name="Order"
                                (selectionChange)="updateProducts($event.value)" style="min-width: 100px !important;">
                                <mat-select-trigger>
                                    {{row?.Order?.Reference}}
                                </mat-select-trigger>
                                <mat-option *ngFor="let order of originalSupplierOrders" [value]="order">
                                    {{order.Reference + ' - ' + order.Subject}}
                                </mat-option>
                            </mat-select>
                        </mat-form-field>
                    </td>
                </ng-container>

TS:

openSelectedOrderProductList(prm) {
    const dialogRef = this._dialog.open(SelectedOrderProductListDialogComponent, {
        width: "700px",
        data: prm,
    });

    dialogRef.afterClosed().subscribe((result) => {
        //console.log(result);
    });
}
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You need to trigger the selectionChange in to open the dialog. Add the "openSelectedOrderProductListfunction()" to (selectionChange).

HTML:

 <ng-container matColumnDef="Order">
  <th mat-header-cell *matHeaderCellDef width="10%"> Sipariş No </th>
  <td mat-cell *matCellDef="let row; let i = index">
      <span *ngIf="EditIndex != i">{{row.Order?.Subject}}</span>
      <mat-form-field floatLabel="never" *ngIf="EditIndex == i" class="w-100-p" style="min-width: 100px !important;">
          <mat-select [(ngModel)]="row.Order" required name="Order"
              (selectionChange)="updateProducts($event.value);openSelectedOrderProductListfunction()" style="min-width: 100px !important;">
              <mat-select-trigger>
                  {{row?.Order?.Reference}}
              </mat-select-trigger>
              <mat-option *ngFor="let order of originalSupplierOrders" [value]="order">
                  {{order.Reference + ' - ' + order.Subject}}
              </mat-option>
          </mat-select>
      </mat-form-field>
  </td>
about 4 years ago · Juan Pablo Isaza Relatório

0

If you are using Reactive forms, I suggest you to use valueChanges, you can refer this answer.

Else you can use just use selectionChange event of <mat-select>

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