Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import {Input, OnInit, Component} from "angular2/core";
  2. import {KeyCodes} from "ng2-material/core/key_codes";
  3.  
  4. @Component({
  5. selector: "mdDialogComplex",
  6. host: {
  7. '(body:keydown)': 'documentKeypress($event)',
  8. },
  9. template: `
  10. <md-backdrop class="md-backdrop md-opaque md-backdrop-absolute md-active" *ngIf="!isClosed" (click)="close()"></md-backdrop>
  11.  
  12. <md-dialog-container class="md-dialog md-dialog-absolute md-active" tabindex="0" *ngIf="!isClosed">
  13. <md-dialog-content><ng-content></ng-content></md-dialog-content>
  14.  
  15. <md-dialog-actions>
  16. <button class="md-primary" md-button="" type="button" (click)="close()"><span class="md-button-wrapper">
  17. <span>Cancel</span>
  18. </span></button>
  19. </md-dialog-actions></md-dialog-container>
  20. `
  21. })
  22. export class MdDialogComplex implements OnInit {
  23. private isClosed = true;
  24.  
  25. ngOnInit() {
  26. this.open();
  27.  
  28. }
  29.  
  30. close() {
  31. this.isClosed = true;
  32. }
  33.  
  34. open() {
  35. this.isClosed = false;
  36. }
  37.  
  38. documentKeypress(event: KeyboardEvent) {
  39. if (event.keyCode == KeyCodes.ESCAPE) {
  40. this.isClosed = true;
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement