我有一个 API 数据列表,但并未显示所有数据。我尝试通过 MatDialog 弹出弹出窗口以呈现更多细节,在这种情况下是“评论”。当然链接到正确的 ReferenceNo/ 列..任何建议?
父组件.ts:
constructor(private service:NilexService , public dialog: MatDialog ) { }
TicketsList:any=[];
ngOnInit(): void {
this.refreshTicList();
}
refreshTicList(){
this.service.getAllTicList().subscribe(data=>{
this.TicketsList =data as string[];
this.TicketsList = new MatTableDataSource(data);
this.TicketsList.sort = this.sort;
this.TicketsList.paginator = this.paginator;
this.TicketsList.tooltrip = this.tooltrip;
});
}
openDialog(element: any): void {
let dialogRef = this.dialog.open(ChildComponent, {
width: '1720px',
height: '500px',
panelClass: 'my-centered-dialog',
data :{ element : this.TicketsList
}
});
dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed');
});
}
父组件.html:
<ng-container class="example-button-container" matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef> actions </th>
<td mat-cell *matCellDef="let element">
<button mat-icon-button (click)="openDialog(element)" >
<mat-icon color= "primary" >open_in_new</mat-icon>
</button>
</td>
ChildComponent.ts:
constructor(
public dialog_ref: MatDialogRef<ShowTicComponent>,
@Inject( MAT_DIALOG_DATA ) public data: any) {
}
ngOnInit() {
}
ChildComponent.html:
<div>
{{data.TicketsList.comment}}
</div>
错误: 在此处输入图像描述