created app with two components(A&B) with popup dialog on edit:
Comp A Fetch the data from service and load to the data table
Comb B initiates the data when pop event fired from A.
typically multiple records are load with array response into the table.
when pop is fired form data loaded correctly for record 1 for record 2 the same value of 1 is getting loaded instead of 2.
used MAT_DIALOG_DATA
to import the table data to B Component.
a unique record to populate in form B
A_component.ts:
open() const dialogconfig = new MatDialogConfig();
dialogconfig.diableClose =true;
this.dialog.open(BComoonent,
{
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">