11< div class ="demo-content ">
2+ < h3 class ="demo-content__headline "> Configuring Dialog via
3+ entryComponents</ h3 >
4+ < p mdcBody2 > Because < code class ="docs-markdown-code "> MdcDialog</ code >
5+ instantiates components at run-time, the
6+ Angular compiler needs extra information to create the necessary
7+ ComponentFactory for your dialog content component.</ p >
8+ < p mdcBody2 > For any component loaded into a dialog, you must include your
9+ component
10+ class in the list of < code class ="docs-markdown-code "> entryComponents</ code >
11+ in your NgModule definition so that
12+ the Angular compiler knows to create the ComponentFactory.</ p >
13+ < pre > < code highlight ="@NgModule({
14+ imports: [
15+ // ...
16+ MdcDialogModule
17+ ],
18+ declarations: [
19+ AppComponent,
20+ ExampleDialogComponent
21+ ],
22+ entryComponents: [
23+ ExampleDialogComponent
24+ ],
25+ bootstrap: [AppComponent]
26+ })
27+ export class AppModule {} "> </ code > </ pre >
28+
229 < h3 class ="demo-content__headline "> Usage</ h3 >
3- A dialog is opened by calling the < code class ="docs-markdown-code "> open</ code > method with a component to be loaded
4- and an optional config object. The < code class ="docs-markdown-code "> open</ code > method will return an instance of
30+ A dialog is opened by calling the < code class ="docs-markdown-code "> open</ code >
31+ method with a component to be loaded
32+ and an optional config object. The < code
33+ class ="docs-markdown-code "> open</ code > method will return an instance of
534 < code class ="docs-markdown-code "> MdcDialogRef</ code > :
635
736 < pre > < code highlight ="let dialogRef = dialog.open(UserProfileComponent, {
837 clickOutsideToClose: true,
938 escapeToClose: true,
1039}); "> </ code > </ pre >
1140
12- The < code class ="docs-markdown-code "> MdcDialogRef</ code > provides a handle on the opened dialog. It can be used to
41+ The < code class ="docs-markdown-code "> MdcDialogRef</ code > provides a handle on
42+ the opened dialog. It can be used to
1343 close the dialog and to receive notification when the dialog has been closed.
1444
1545 < pre > < code highlight ="dialogRef.afterClosed().subscribe(result => {
@@ -18,9 +48,12 @@ <h3 class="demo-content__headline">Usage</h3>
1848
1949dialogRef.close('Pizza!'); "> </ code > </ pre >
2050
21- < p > Components created via < code class ="docs-markdown-code "> MdcDialog</ code > can inject < code class ="docs-markdown-code "> MdcDialogRef</ code >
22- and use it to close the dialog in which they are contained. When closing, an optional result value can be
23- provided. This result value is forwarded as the result of the < code class ="docs-markdown-code "> afterClosed</ code >
51+ < p > Components created via < code class ="docs-markdown-code "> MdcDialog</ code >
52+ can inject < code class ="docs-markdown-code "> MdcDialogRef</ code >
53+ and use it to close the dialog in which they are contained. When closing, an
54+ optional result value can be
55+ provided. This result value is forwarded as the result of the < code
56+ class ="docs-markdown-code "> afterClosed</ code >
2457 promise.</ p >
2558
2659 < pre > < code highlight ="@Component({/* ... */})
@@ -34,7 +67,8 @@ <h3 class="demo-content__headline">Usage</h3>
3467} "> </ code > </ pre >
3568
3669 < h3 class ="demo-content__headline "> Sharing data with the Dialog component</ h3 >
37- If you want to share data with your dialog, you can use the < code class ="docs-markdown-code "> data</ code > option to
70+ If you want to share data with your dialog, you can use the < code
71+ class ="docs-markdown-code "> data</ code > option to
3872 pass information to the dialog component.
3973
4074 < pre > < code highlight ="let dialogRef = dialog.open(YourDialog, {
@@ -59,26 +93,4 @@ <h3 class="demo-content__headline">Sharing data with the Dialog component</h3>
5993 userName: string = data.name;
6094 }
6195} "> </ code > </ pre >
62- < h3 class ="demo-content__headline "> Configuring dialog content via entryComponents</ h3 >
63- < p mdcBody2 > Because < code class ="docs-markdown-code "> MdcDialog</ code > instantiates components at run-time, the
64- Angular compiler needs extra information to create the necessary
65- ComponentFactory for your dialog content component.</ p >
66- < p mdcBody2 > For any component loaded into a dialog, you must include your component
67- class in the list of < code class ="docs-markdown-code "> entryComponents</ code > in your NgModule definition so that
68- the Angular compiler knows to create the ComponentFactory.</ p >
69- < pre > < code highlight ="@NgModule({
70- imports: [
71- // ...
72- MdcDialogModule
73- ],
74- declarations: [
75- AppComponent,
76- ExampleDialogComponent
77- ],
78- entryComponents: [
79- ExampleDialogComponent
80- ],
81- bootstrap: [AppComponent]
82- })
83- export class AppModule {} "> </ code > </ pre >
84- </ div >
96+ </ div >
0 commit comments