Skip to content

Commit 0dab2b5

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 eef132b commit 0dab2b5

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/material/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/material/dialog/dialog.ts

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

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

0 commit comments

Comments
 (0)