BsModalService confirmation modal with yes and no buttons
See original GitHub issueGreetings, I am using BsModalService with component. i have a modal with two buttons yes and no.
I would like to know how to track which button clicked. here yes or no button. I have gone through demo, but i could not find any solution.
let bsModalRef = this.modalService.show(ConfirmDeleteComponent, { animated: true, keyboard: true, backdrop: true, ignoreBackdropClick: false });
My modal html:
<div class="alert-box">
<div class="modal-header">
<h4 class="modal-title">Confirm</h4>
<button type="button" class="close" aria-label="Close" (click)="bsModalRef.hide()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Are you sure want to delete this node?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" (click)="bsModalRef.hide()">Yes</button>
<button type="button" class="btn btn-secondary" (click)="bsModalRef.hide()">No</button>
</div>
</div>
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (3 by maintainers)
Top Results From Across the Web
ngx-bootstrap modal: How to get a return value from a modal?
What if instead I would like to show an ngx-bootstrap modal with, let's say, two buttons "Yes" or "No" and obtain a similar...
Read more >Modal - Angular powered Bootstrap
You can pass an existing component as content of the modal window. ... For Angular 9 or newer, it's not needed anymore. ......
Read more >Angular - How to create a Modal Dialog - Zone of Development
In detail, we will create a modal dialog in order to delete a single ... class="btn btn-primary" (click)="confirm()" >Yes</button> <button ...
Read more >Confirm Dialog In Angular Using Bootstrap Modal - C# Corner
This article shows how to create a custom component for Confirm Dialog in Angular using modal popup of bootstrap.
Read more >ion-modal: Ionic Mobile App Custom Modal API Component
As this functionality is provided by the JavaScript framework, using ion-modal without a JavaScript framework will not destroy the component you passed in....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A possible solution could be:
confirmation-modal.component.html
confirmation-modal.component.ts:
opening the modal with the modal service from another component:
Hi,
am I the only one who thinks this is highly inconvenient? So much boilerplate code for a very common use case. Passing data to the modal was implemented in July (see #2290), so I think that subscribing to a generic result of the modal should be implemented too. To be honest, I like the approach of this little npm package here: https://www.npmjs.com/package/ng2-bootstrap-modal but that is just a suggestion.
@valorkin Any chance something like this finds its way into ngx-bootstrap?