I\'m trying to use a dialog component in Angular 2 using @angular/material2.0.0-beta.1. What I\'m trying to accomplish is to send data (which are values that a
Update: Definitely use the above Inject method to get your data. This way is dependent upon accessing a private member which is not guaranteed to remain untouched between versions
If you're using the new 2.0.0 beta 3 (or maybe it was even changed in beta 2, not sure) then the above answer has to be changed a little bit:
@Component({
selector: "dialog",
templateUrl: "./dialog.component.html"
})
export class DialogComponent {
constructor(public dialogRef: MdDialogRef) { }
type: string;
name: string;
ngOnInit(): void {
let configData: any = this.dialogRef._containerInstance.dialogConfig.data;
this.type = configData.type;
this.name = configData.name;
}
}
It seems like there should be a better way of referencing the data than this.dialogRef._containerInstance.dialogConfig.data but I couldn't find one