From 46d0b6f4bebbb46cd72a3cb5f81bcb28628926bc Mon Sep 17 00:00:00 2001 From: Will Howell Date: Mon, 10 Jul 2017 15:18:47 -0400 Subject: [PATCH] docs(dialog): example of how to inject MdDialogRef (#5311) --- src/lib/dialog/dialog.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lib/dialog/dialog.md b/src/lib/dialog/dialog.md index 7ff2099f3d9..35afa748b97 100644 --- a/src/lib/dialog/dialog.md +++ b/src/lib/dialog/dialog.md @@ -29,6 +29,17 @@ Components created via `MdDialog` can _inject_ `MdDialogRef` and use it to close in which they are contained. When closing, an optional result value can be provided. This result value is forwarded as the result of the `afterClosed` promise. +```ts +@Component({/* ... */}) +export class YourDialog { + constructor(public dialogRef: MdDialogRef) { } + + closeDialog() { + this.dialogRef.close('Pizza!'); + } +} +``` + ### 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.