Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dialog): support passing in dialog result through all MdDialogClose selectors #6293

Merged
merged 1 commit into from
Aug 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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