I need to show data in JSON view inside MatDialog. I am using an API to fetch some data and then injecting it into the dialog box using data
option of MatDialog
. Data is being injected successfully and also accessible in the dialog component. I'm using ngx-json-viewer package to display this data in JSON view but it's not working.
Here's how I'm opening the dialog box and passing data into it-
const logDetailsDialogRef = this.dialog.open(logDetailsDialog, {
data: {
logDetails
}
});
And here is what I am using on my template page-
<ngx-json-viewer [json]="data.logDetails"></ngx-json-viewer>
You must inject @Inject(MAT_DIALOG_DATA) public data in your constructor.
this remains the same: