Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

passing data to a MatDialog component using inject

this.dialogRef = this.dialog.open(someComponent, {
  data: {
    myInfo: infoId
  }
});

//on the MatDialog component 
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { Inject } from '@angular/core';

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

ngOnInit() {
  // will log the entire data object
  console.log(this.data)
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #passing #data #MatDialog #component #inject
ADD COMMENT
Topic
Name
5+5 =