mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
chore(dialog): add generic param for config data (#7447)
Adds a generic parameter to the `MatDialogConfig` that indicates the type of its `data`. BREAKING CHANGE: Material now requires at least TypeScript 2.4. Fixes #4398.
This commit is contained in:
committed by
Andrew Seguin
parent
b6f7f1740b
commit
b29ac45c0b
@@ -23,7 +23,7 @@ export interface DialogPosition {
|
||||
/**
|
||||
* Configuration for opening a modal dialog with the MatDialog service.
|
||||
*/
|
||||
export class MatDialogConfig {
|
||||
export class MatDialogConfig<D = any> {
|
||||
|
||||
/**
|
||||
* Where the attached component should live in Angular's *logical* component tree.
|
||||
@@ -73,7 +73,7 @@ export class MatDialogConfig {
|
||||
position?: DialogPosition;
|
||||
|
||||
/** Data being injected into the child component. */
|
||||
data?: any = null;
|
||||
data?: D | null = null;
|
||||
|
||||
/** Layout direction for the dialog's content. */
|
||||
direction?: Direction = 'ltr';
|
||||
|
||||
@@ -114,8 +114,8 @@ export class MatDialog {
|
||||
* @param config Extra configuration options.
|
||||
* @returns Reference to the newly-opened dialog.
|
||||
*/
|
||||
open<T>(componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
|
||||
config?: MatDialogConfig): MatDialogRef<T> {
|
||||
open<T, D = any>(componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
|
||||
config?: MatDialogConfig<D>): MatDialogRef<T> {
|
||||
|
||||
const inProgressDialog = this.openDialogs.find(dialog => dialog._isAnimating());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user