Skip to content

Commit

Permalink
fix(dialog): support passing in dialog result through all MdDialogClo…
Browse files Browse the repository at this point in the history
…se selectors (#6293)

Fixes not being able to pass in a dialog result through the `mdDialogClose`, `matDialogClose` and `mat-dialog-close` selectors, even though they are allowed by the `MdDialogClose` directive.

Fixes #6278.
  • Loading branch information
crisbeto authored and mmalerba committed Aug 8, 2017
1 parent 4ae1b0f commit 4a1f10e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/lib/dialog/dialog-content-directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {Directive, Input, Optional, OnInit} from '@angular/core';
import {Directive, Input, OnChanges, OnInit, Optional, SimpleChanges} from '@angular/core';
import {MdDialogRef} from './dialog-ref';
import {MdDialogContainer} from './dialog-container';

Expand All @@ -25,17 +25,27 @@ let dialogElementUid = 0;
'type': 'button', // Prevents accidental form submits.
}
})
export class MdDialogClose {
export class MdDialogClose implements OnChanges {
/** Screenreader label for the button. */
@Input('aria-label') ariaLabel: string = 'Close dialog';

/** Dialog close input. */
@Input('md-dialog-close') dialogResult: any;

/** Dialog close input for compatibility mode. */
@Input('mat-dialog-close') set _matDialogClose(value: any) { this.dialogResult = value; }
@Input('matDialogClose') _matDialogClose: any;
@Input('mdDialogClose') _mdDialogClose: any;
@Input('mat-dialog-close') _matDialogCloseResult: any;

constructor(public dialogRef: MdDialogRef<any>) { }

ngOnChanges(changes: SimpleChanges) {
const proxiedChange = changes._matDialogClose || changes._mdDialogClose ||
changes._matDialogCloseResult;

if (proxiedChange) {
this.dialogResult = proxiedChange.currentValue;
}
}
}

/**
Expand Down

0 comments on commit 4a1f10e

Please sign in to comment.