Skip to content

Commit 61c3644

Browse files
committed
docs(dialog): Add note about AOT compilation.
Add a note to the `MdDialog` documentation discussing proper usage with the Ahead of Time compiler. Also fix a small typo in the Portal docs. Fixes #2686.
1 parent c203589 commit 61c3644

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/lib/core/portal/portal.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class ComponentPortal<T> extends Portal<ComponentRef<T>> {
7474
/**
7575
* [Optional] Where the attached component should live in Angular's *logical* component tree.
7676
* This is different from where the component *renders*, which is determined by the PortalHost.
77-
* The origin necessary when the host is outside of the Angular application context.
77+
* The origin is necessary when the host is outside of the Angular application context.
7878
*/
7979
viewContainerRef: ViewContainerRef;
8080

src/lib/dialog/dialog.md

+31
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,34 @@ You can control which elements are tab stops with the `tabindex` attribute
4646
```html
4747
<button md-button tabindex="-1">Not Tabbable</button>
4848
```
49+
50+
### AOT Compilation
51+
52+
Due to the dynamic nature of the `MdDialog`, and it's usage of `ViewContainerRef#createComponent()`
53+
to create the component on the fly, the AOT compiler will not know to create the proper
54+
`ComponentFactory` for your dialog component by default.
55+
56+
You must include your dialog class in the list of `entryComponents` in your module definition so
57+
that the AOT compiler knows to create the `ComponentFactory` for it.
58+
59+
```ts
60+
@NgModule({
61+
imports: [
62+
// ...
63+
MaterialModule.forRoot()
64+
],
65+
66+
declarations: [
67+
AppComponent,
68+
ExampleDialogComponent
69+
],
70+
71+
entryComponents: [
72+
ExampleDialogComponent
73+
]
74+
75+
providers: [],
76+
bootstrap: [AppComponent]
77+
})
78+
export class AppModule() {}
79+
```

0 commit comments

Comments
 (0)