Skip to content

Commit c98efaf

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 0f17f16 commit c98efaf

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
@@ -43,8 +43,21 @@ export class MatBottomSheet {
4343
private _injector: Injector,
4444
@Optional() @SkipSelf() private _parentBottomSheet: MatBottomSheet) {}
4545

46+
/**
47+
* Opens a bottom sheet containing the given component.
48+
* @param component Type of the component to load into the bottom sheet.
49+
* @param config Extra configuration options.
50+
* @returns Reference to the newly-opened bottom sheet.
51+
*/
4652
open<T, D = any, R = any>(component: ComponentType<T>,
4753
config?: MatBottomSheetConfig<D>): MatBottomSheetRef<T, R>;
54+
55+
/**
56+
* Opens a bottom sheet containing the given template.
57+
* @param template TemplateRef to instantiate as the bottom sheet content.
58+
* @param config Extra configuration options.
59+
* @returns Reference to the newly-opened bottom sheet.
60+
*/
4861
open<T, D = any, R = any>(template: TemplateRef<T>,
4962
config?: MatBottomSheetConfig<D>): MatBottomSheetRef<T, R>;
5063

src/lib/dialog/dialog.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,22 @@ export class MatDialog {
106106

107107
/**
108108
* Opens a modal dialog containing the given component.
109-
* @param componentOrTemplateRef Type of the component to load into the dialog,
110-
* or a TemplateRef to instantiate as the dialog content.
109+
* @param component Type of the component to load into the dialog.
111110
* @param config Extra configuration options.
112111
* @returns Reference to the newly-opened dialog.
113112
*/
113+
open<T, D = any, R = any>(component: ComponentType<T>,
114+
config?: MatDialogConfig<D>): MatDialogRef<T, R>;
115+
116+
/**
117+
* Opens a modal dialog containing the given template.
118+
* @param template TemplateRef to instantiate as the dialog content.
119+
* @param config Extra configuration options.
120+
* @returns Reference to the newly-opened dialog.
121+
*/
122+
open<T, D = any, R = any>(template: TemplateRef<T>,
123+
config?: MatDialogConfig<D>): MatDialogRef<T, R>;
124+
114125
open<T, D = any, R = any>(componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
115126
config?: MatDialogConfig<D>): MatDialogRef<T, R> {
116127

0 commit comments

Comments
 (0)