docs(dialog): address injecting dialog data (#3907)

This commit is contained in:
Mac
2017-04-17 11:40:57 -07:00
committed by Jeremy Elbourn
parent 5c3278a4cb
commit 9f2c7aca2e
+24
View File
@@ -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: