-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(dialog): add ability to open dialog with templateRef #2853
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
Changes from 5 commits
ad9617f
14ef81c
bd19bd3
dbb1676
1803505
9a0a28b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,7 @@ | |
| max-width: 350px; | ||
| margin: 20px 0; | ||
| } | ||
|
|
||
| .demo-button-group { | ||
| margin-bottom: 20px; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,10 +14,18 @@ export class MdDialogRef<T> { | |
| /** The instance of component opened into the dialog. */ | ||
| componentInstance: T; | ||
|
|
||
| /** Expose overlay backdrop click event */ | ||
| backdropClicked: Observable<void>; | ||
|
||
|
|
||
| /** Subject for notifying the user that esc key way pressed */ | ||
| escapePressed = new Subject<void>(); | ||
|
||
|
|
||
| /** Subject for notifying the user that the dialog has finished closing. */ | ||
| private _afterClosed: Subject<any> = new Subject(); | ||
|
|
||
| constructor(private _overlayRef: OverlayRef) { } | ||
| constructor(private _overlayRef: OverlayRef) { | ||
| this.backdropClicked = this._overlayRef.backdropClick(); | ||
| } | ||
|
|
||
| /** | ||
| * Close the dialog. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
TemplateRefshould be instantiated indialog.tsand we should just callattachon the dialog container (fromBasePortalHost) that will delegate to the appropriate method.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand this correctly, but to be able to create a portal, you need ViewContainerRef, which is not accessible inside
dialog.ts. In my previous PR I hadMdDialog.openFromPortal(), but I think it a little too tedious for user to have to create a portal rather than to be just able to pass inTemplateRef. But I don't really mind either.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I could make
ViewTemplateRefavailable todialog.ts.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about types thought, wouldn't you lose them by just calling
attachinstead ofattachComponentPortal/attachTemplatePortal?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also if I just use
attach, typescript will complain about not properly implementingattachTemplatePortalandattachComponentPortal.. what should I do please, @jelbourn ?