Skip to content

Instantly share code, notes, and snippets.

@AlexanderKozhevin
Created May 7, 2017 10:43
Show Gist options
  • Save AlexanderKozhevin/57250919a676b98f3cecca0a8daa9529 to your computer and use it in GitHub Desktop.
Save AlexanderKozhevin/57250919a676b98f3cecca0a8daa9529 to your computer and use it in GitHub Desktop.
<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">&times;</span>
</button>
</div>
<div class="modal-body">
<p>One fine body&hellip;</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