diff --git a/src/lib/dialog/dialog.md b/src/lib/dialog/dialog.md index 622f4b724294..70272dd6aae0 100644 --- a/src/lib/dialog/dialog.md +++ b/src/lib/dialog/dialog.md @@ -29,6 +29,30 @@ 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. +### 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. + +```ts +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: +```ts +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) { } +} +``` + ### Dialog content Several directives are available to make it easier to structure your dialog content: