File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,30 @@ Components created via `MdDialog` can _inject_ `MdDialogRef` and use it to close
2929in which they are contained. When closing, an optional result value can be provided. This result
3030value is forwarded as the result of the ` afterClosed ` promise.
3131
32+ ### Sharing data with the Dialog component.
33+ If you want to share data with your dialog, you can use the ` data ` option to pass information to the dialog component.
34+
35+ ``` ts
36+ let dialogRef = dialog .open (YourDialog , {
37+ data: ' your data' ,
38+ });
39+ ```
40+
41+ To access the data in your dialog component, you have to use the MD_DIALOG_DATA injection token:
42+ ``` ts
43+ import {Component , Inject } from ' @angular/core' ;
44+ import {MD_DIALOG_DATA } from ' @angular/material' ;
45+
46+ @Component ({
47+ selector: ' your-dialog' ,
48+ template: ' passed in {{ data }}' ,
49+ })
50+
51+ export class YourDialog {
52+ constructor (@Inject (MD_DIALOG_DATA ) public data : any ) { }
53+ }
54+ ```
55+
3256### Dialog content
3357Several directives are available to make it easier to structure your dialog content:
3458
You can’t perform that action at this time.
0 commit comments