-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(modal): add demo for confirm window (#2814)
* docs(modal): add demo for confirm window * docs(modal): beautify confirm window demo
- Loading branch information
1 parent
eccb382
commit e98109c
Showing
4 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
10 changes: 10 additions & 0 deletions
10
demo/src/app/components/+modal/demos/service-confirm-window/service-confirm-window.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<button type="button" class="btn btn-primary" (click)="openModal(template)">Open modal</button> | ||
<br><br> | ||
<pre>{{message}}</pre> | ||
<ng-template #template> | ||
<div class="modal-body text-center"> | ||
<p>Do you want to confirm?</p> | ||
<button type="button" class="btn btn-default" (click)="confirm()" >Yes</button> | ||
<button type="button" class="btn btn-primary" (click)="decline()" >No</button> | ||
</div> | ||
</ng-template> |
27 changes: 27 additions & 0 deletions
27
demo/src/app/components/+modal/demos/service-confirm-window/service-confirm-window.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Component, TemplateRef } from '@angular/core'; | ||
import { BsModalService } from 'ngx-bootstrap/modal'; | ||
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; | ||
|
||
@Component({ | ||
selector: 'demo-modal-service-confirm-window', | ||
templateUrl: './service-confirm-window.html' | ||
}) | ||
export class DemoModalServiceConfirmWindowComponent { | ||
modalRef: BsModalRef; | ||
message: string; | ||
constructor(private modalService: BsModalService) {} | ||
|
||
openModal(template: TemplateRef<any>) { | ||
this.modalRef = this.modalService.show(template, {class: 'modal-sm'}); | ||
} | ||
|
||
confirm(): void { | ||
this.message = 'Confirmed!'; | ||
this.modalRef.hide(); | ||
} | ||
|
||
decline(): void { | ||
this.message = 'Declined!'; | ||
this.modalRef.hide(); | ||
} | ||
} |
This file contains 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