Developed an application with two components (A & B) that includes a popup dialog for editing:
Component A fetches the data from a service and loads it into a data table
Component B initializes the data when a pop event is triggered from A.
Usually, multiple records are loaded with an array response into the table.
However, there seems to be an issue where when a pop event is fired, the data is correctly loaded for record 1 but for record 2, the same value as record 1 is displayed instead of its own.
We utilized MAT_DIALOG_DATA
to import the table data into Component B.
The goal here is to have a unique record populate in form B
A_component.ts:
open() const dialogconfig = new MatDialogConfig();
dialogconfig.diableClose =true;
this.dialog.open(BComponent,
{
data: this.datasource
});
BComponent.ts
constructor(@inject((MAT_DIALOG_DATA public) data:any;)
and HTML Code:
<input matInput placeholder="First Name " id="" name=" [ngModel]="data[0].empName">