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

103
Visualizações
how to pass a row data or the object of an array to a component in Angular using MatDialog

What I want is that, when I click on the specific row's button, it should open up a matDialog box which should display me all the contents of the row. This is the html file,

                           <tr *ngFor="let u of users">
                                <td data-label="ID">{{u.name}}</td>
                                <td>
                                    <button (click)="toggle(u)" mat-button type="button" class="btn btn-primary">
                                        Show Details
                                    </button>
                                </td>
                            </tr>

And this is my ts file.


users = [
    {
      'name':'arjun'
    },
    {
      'name':'Karan'
    }
  ]


toggle(userRow:any){
    const dialogConfig = new MatDialogConfig();
    dialogConfig.disableClose = false;
    dialogConfig.autoFocus = true;
    dialogConfig.width="60%";
    this.dialog.open(UserDetailsPopupComponent, dialogConfig);
  }

And this is my html file of the component(UserDetailsPopUp) that will open using MatDialogue.

<h1>Hello{{u.name}}</h1>

But I'm not able to send the row data from the toggle function to this component. How do I do that? And load that data and display it.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Send data to the dialog component like this:

toggle(userRow:any){
    const dialogConfig = new MatDialogConfig();
    dialogConfig.disableClose = false;
    dialogConfig.autoFocus = true;
    dialogConfig.width="60%";
    dialogConfig.data = userRow;
    this.dialog.open(UserDetailsPopupComponent, dialogConfig);
  }

and to catch the data in UserDetailsPopupComponent

constructor(@Inject(MAT_DIALOG_DATA) public _data: any) {}

_data contains the userRow data.

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