Created
May 7, 2017 10:43
-
-
Save AlexanderKozhevin/57250919a676b98f3cecca0a8daa9529 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ng-template #content let-c="close" let-d="dismiss"> | |
<div class="modal-header"> | |
<h4 class="modal-title">Modal title</h4> | |
<button type="button" class="close" aria-label="Close" (click)="d('Cross click')"> | |
<span aria-hidden="true">×</span> | |
</button> | |
</div> | |
<div class="modal-body"> | |
<p>One fine body…</p> | |
</div> | |
<div class="modal-footer"> | |
<button type="button" class="btn btn-secondary" (click)="c('Close click')">Close</button> | |
</div> | |
</ng-template> | |
<button class="btn btn-lg btn-outline-primary" (click)="open(content)">Launch demo modal</button> | |
closeResult: string; | |
open(content) { | |
this.modalService.open(content).result.then((result) => { | |
this.closeResult = Closed with: result; | |
}, (reason) => { | |
this.closeResult = Dismissed reason; | |
}); | |
} | |
private getDismissReason(reason: any): string { | |
console.log(reason) | |
if (reason === ModalDismissReasons.ESC) { | |
return 'by pressing ESC'; | |
} else if (reason === ModalDismissReasons.BACKDROP_CLICK) { | |
return 'by clicking on a backdrop'; | |
} else { | |
return 'reason'; | |
} | |
} | |
constructor(private modalService: NgbModal){ | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment