Skip to content

Commit

Permalink
chore(dialog): add generic param for config data
Browse files Browse the repository at this point in the history
Adds a generic parameter to the `MatDialogConfig` that indicates the type of its `data`.

Fixes angular#4398.
  • Loading branch information
crisbeto committed Sep 30, 2017
1 parent 3c6f7a2 commit 2e41711
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/demo-app/dialog/dialog-demo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, Inject, ViewChild, TemplateRef} from '@angular/core';
import {DOCUMENT} from '@angular/platform-browser';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
import {MatDialog, MatDialogRef, MatDialogConfig, MAT_DIALOG_DATA} from '@angular/material';


@Component({
Expand All @@ -14,7 +14,7 @@ export class DialogDemo {
lastAfterClosedResult: string;
lastBeforeCloseResult: string;
actionsAlignment: string;
config = {
config: MatDialogConfig = {
disableClose: false,
panelClass: 'custom-overlay-pane-class',
hasBackdrop: true,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/dialog/dialog-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -61,7 +61,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';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down

0 comments on commit 2e41711

Please sign in to comment.