diff --git a/src/demo-app/demo-app-module.ts b/src/demo-app/demo-app-module.ts
index 47b54dbb1036..8454f65ddd5f 100644
--- a/src/demo-app/demo-app-module.ts
+++ b/src/demo-app/demo-app-module.ts
@@ -8,7 +8,14 @@ import {MaterialModule, OverlayContainer,
FullscreenOverlayContainer} from '@angular/material';
import {DEMO_APP_ROUTES} from './demo-app/routes';
import {ProgressBarDemo} from './progress-bar/progress-bar-demo';
-import {JazzDialog, ContentElementDialog, DialogDemo, IFrameDialog} from './dialog/dialog-demo';
+import {
+ JazzDialog,
+ JazzDialogTemplateRef,
+ ContentElementDialog,
+ ContentElementTemplateRefDialog,
+ DialogDemo,
+ IFrameDialog
+} from './dialog/dialog-demo';
import {RippleDemo} from './ripple/ripple-demo';
import {IconDemo} from './icon/icon-demo';
import {GesturesDemo} from './gestures/gestures-demo';
@@ -64,7 +71,9 @@ import {InputContainerDemo} from './input/input-container-demo';
IconDemo,
InputContainerDemo,
JazzDialog,
+ JazzDialogTemplateRef,
ContentElementDialog,
+ ContentElementTemplateRefDialog,
IFrameDialog,
ListDemo,
LiveAnnouncerDemo,
@@ -100,7 +109,9 @@ import {InputContainerDemo} from './input/input-container-demo';
entryComponents: [
DemoApp,
JazzDialog,
+ JazzDialogTemplateRef,
ContentElementDialog,
+ ContentElementTemplateRefDialog,
IFrameDialog,
RotiniPanel,
ScienceJoke,
diff --git a/src/demo-app/dialog/dialog-demo.html b/src/demo-app/dialog/dialog-demo.html
index 53734bbbfdff..ec6cf69cb0e5 100644
--- a/src/demo-app/dialog/dialog-demo.html
+++ b/src/demo-app/dialog/dialog-demo.html
@@ -1,7 +1,15 @@
Dialog demo
-
-
+
+
+
+
+
+
+
+
+
+
@@ -51,3 +59,12 @@ Other options
Last close result: {{lastCloseResult}}
+
+
+
+
+
+
+
+
+
diff --git a/src/demo-app/dialog/dialog-demo.scss b/src/demo-app/dialog/dialog-demo.scss
index 6f7f4cac254a..8d1f33274c67 100644
--- a/src/demo-app/dialog/dialog-demo.scss
+++ b/src/demo-app/dialog/dialog-demo.scss
@@ -6,3 +6,7 @@
max-width: 350px;
margin: 20px 0;
}
+
+.demo-button-group {
+ margin-bottom: 20px;
+}
diff --git a/src/demo-app/dialog/dialog-demo.ts b/src/demo-app/dialog/dialog-demo.ts
index 5e91c097f9aa..623e41b5b28c 100644
--- a/src/demo-app/dialog/dialog-demo.ts
+++ b/src/demo-app/dialog/dialog-demo.ts
@@ -1,4 +1,12 @@
-import {Component, Inject} from '@angular/core';
+import {
+ Component,
+ Inject,
+ Input,
+ Output,
+ ViewChild,
+ TemplateRef,
+ EventEmitter
+} from '@angular/core';
import {DOCUMENT} from '@angular/platform-browser';
import {MdDialog, MdDialogRef, MdDialogConfig} from '@angular/material';
@@ -9,7 +17,15 @@ import {MdDialog, MdDialogRef, MdDialogConfig} from '@angular/material';
styleUrls: ['dialog-demo.css'],
})
export class DialogDemo {
+ @ViewChild('jazzDialogRef')
+ jazzDialogRef: TemplateRef;
+
+ @ViewChild('contentElementRef')
+ contentElementRef: TemplateRef;
+
dialogRef: MdDialogRef;
+ dialogTemplateRef: MdDialogRef;
+ dialogContentTemplateRef: MdDialogRef;
lastCloseResult: string;
actionsAlignment: string;
config: MdDialogConfig = {
@@ -41,16 +57,43 @@ export class DialogDemo {
openJazz() {
this.dialogRef = this.dialog.open(JazzDialog, this.config);
- this.dialogRef.afterClosed().subscribe(result => {
+ this.dialogRef.afterClosed().first().subscribe(result => {
this.lastCloseResult = result;
this.dialogRef = null;
});
}
+ openJazzUsingTemplateRef() {
+ this.dialogTemplateRef = this.dialog.openFromTemplate(this.jazzDialogRef, this.config);
+
+ this.dialogTemplateRef.afterClosed().first().subscribe(() => {
+ this.dialogTemplateRef = null;
+ });
+ }
+
+ closeJazzUsingTemplateRef(result: string) {
+ this.lastCloseResult = result;
+
+ this.dialogTemplateRef.close();
+ }
+
openContentElement() {
let dialogRef = this.dialog.open(ContentElementDialog, this.config);
dialogRef.componentInstance.actionsAlignment = this.actionsAlignment;
}
+
+ openContentElementUsingTemplateRef() {
+ this.dialogContentTemplateRef = this.dialog.openFromTemplate(
+ this.contentElementRef,
+ this.config
+ );
+ }
+
+ closeContentElementUsingTemplateRef() {
+ if (this.dialogContentTemplateRef) {
+ this.dialogContentTemplateRef.close();
+ }
+ }
}
@@ -69,6 +112,24 @@ export class JazzDialog {
}
+@Component({
+ selector: 'demo-jazz-dialog-template-ref',
+ template: `
+ It's Jazz!
+
+ {{ jazzMessage }}
+ `
+})
+export class JazzDialogTemplateRef {
+ jazzMessage = 'Jazzy jazz jazz';
+
+ @Output()
+ close = new EventEmitter(false);
+
+ constructor() { }
+}
+
+
@Component({
selector: 'demo-content-element-dialog',
styles: [
@@ -98,13 +159,12 @@ export class JazzDialog {
md-raised-button
color="primary"
md-dialog-close>Close
-
Read more on Wikipedia
-
+