For mdDialog, how do I pass in variable? Specifically, how to inject an Angular service into the dialog component?
From the official docs found on https://material.angular.io/components/dialog/overview
Sharing data with the Dialog component.
If you want to share data with your dialog, you can use the data option to pass information to the dialog component.
let dialogRef = dialog.open(YourDialog, {
data: 'your data',
});
To access the data in your dialog component, you have to use the MD_DIALOG_DATA injection token:
import {Component, Inject} from '@angular/core';
import {MD_DIALOG_DATA} from '@angular/material';
@Component({
selector: 'your-dialog',
template: 'passed in {{ data }}',
})
export class YourDialog {
constructor(@Inject(MD_DIALOG_DATA) public data: any) { }
}