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
29
29
in which they are contained. When closing, an optional result value can be provided. This result
30
30
value is forwarded as the result of the ` afterClosed ` promise.
31
31
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
+
32
56
### Dialog content
33
57
Several directives are available to make it easier to structure your dialog content:
34
58
You can’t perform that action at this time.
0 commit comments