Skip to content

Commit 0ea193c

Browse files
committed
refactor(dialog): use type overload for open method
* Reworks the `MatDialog.open` method to use overloads, rather than the single signature that has `componentOrTemplateRef: ComponentType<T> | TemplateRef<T>`. This makes the separation clearer and looks nicer in autocompletion. * Adds docs for the `MatBottomSheet.open` method.
1 parent 391a9fd commit 0ea193c

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/lib/bottom-sheet/bottom-sheet.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,21 @@ export class MatBottomSheet implements OnDestroy {
6161
@Optional() @Inject(MAT_BOTTOM_SHEET_DEFAULT_OPTIONS)
6262
private _defaultOptions?: MatBottomSheetConfig) {}
6363

64+
/**
65+
* Opens a bottom sheet containing the given component.
66+
* @param component Type of the component to load into the bottom sheet.
67+
* @param config Extra configuration options.
68+
* @returns Reference to the newly-opened bottom sheet.
69+
*/
6470
open<T, D = any, R = any>(component: ComponentType<T>,
6571
config?: MatBottomSheetConfig<D>): MatBottomSheetRef<T, R>;
72+
73+
/**
74+
* Opens a bottom sheet containing the given template.
75+
* @param template TemplateRef to instantiate as the bottom sheet content.
76+
* @param config Extra configuration options.
77+
* @returns Reference to the newly-opened bottom sheet.
78+
*/
6679
open<T, D = any, R = any>(template: TemplateRef<T>,
6780
config?: MatBottomSheetConfig<D>): MatBottomSheetRef<T, R>;
6881

src/lib/dialog/dialog.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,22 @@ export class MatDialog implements OnDestroy {
119119

120120
/**
121121
* Opens a modal dialog containing the given component.
122-
* @param componentOrTemplateRef Type of the component to load into the dialog,
123-
* or a TemplateRef to instantiate as the dialog content.
122+
* @param component Type of the component to load into the dialog.
124123
* @param config Extra configuration options.
125124
* @returns Reference to the newly-opened dialog.
126125
*/
126+
open<T, D = any, R = any>(component: ComponentType<T>,
127+
config?: MatDialogConfig<D>): MatDialogRef<T, R>;
128+
129+
/**
130+
* Opens a modal dialog containing the given template.
131+
* @param template TemplateRef to instantiate as the dialog content.
132+
* @param config Extra configuration options.
133+
* @returns Reference to the newly-opened dialog.
134+
*/
135+
open<T, D = any, R = any>(template: TemplateRef<T>,
136+
config?: MatDialogConfig<D>): MatDialogRef<T, R>;
137+
127138
open<T, D = any, R = any>(componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
128139
config?: MatDialogConfig<D>): MatDialogRef<T, R> {
129140

0 commit comments

Comments
 (0)