Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {Input, OnInit, Component} from "angular2/core";
- import {KeyCodes} from "ng2-material/core/key_codes";
- @Component({
- selector: "mdDialogComplex",
- host: {
- '(body:keydown)': 'documentKeypress($event)',
- },
- template: `
- <md-backdrop class="md-backdrop md-opaque md-backdrop-absolute md-active" *ngIf="!isClosed" (click)="close()"></md-backdrop>
- <md-dialog-container class="md-dialog md-dialog-absolute md-active" tabindex="0" *ngIf="!isClosed">
- <md-dialog-content><ng-content></ng-content></md-dialog-content>
- <md-dialog-actions>
- <button class="md-primary" md-button="" type="button" (click)="close()"><span class="md-button-wrapper">
- <span>Cancel</span>
- </span></button>
- </md-dialog-actions></md-dialog-container>
- `
- })
- export class MdDialogComplex implements OnInit {
- private isClosed = true;
- ngOnInit() {
- this.open();
- }
- close() {
- this.isClosed = true;
- }
- open() {
- this.isClosed = false;
- }
- documentKeypress(event: KeyboardEvent) {
- if (event.keyCode == KeyCodes.ESCAPE) {
- this.isClosed = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement