valor-software / ngx-bootstrap

Fast and reliable Bootstrap widgets in Angular (supports Ivy engine)
https://valor-software.com/ngx-bootstrap
MIT License
5.53k stars 1.69k forks source link

No built in way to get result from BsModalRef #5008

Open devel112 opened 5 years ago

devel112 commented 5 years ago

Ususally opens a modal for a result or a response from user. BsModalRef doesn't give us any opertunity to get the result. Using the service is unreliable as multiple modals can be openened while needing to get result from specific BsModalRef. Sure, can boilerplate a callback function every time but should be built in. What am i missing

Before opening an issue, please search for duplicates (opened and closed) https://github.com/valor-software/ngx-bootstrap/issues There's no need to open an issue here if you want to ask general question, use StackOverflow or Slack instead

Bug description or feature request:

Plunker/StackBlitz that reproduces the issue:

Using Plunkr, StackBlitz is the best way to show your issue. Issues without link to an example of reproduction might be closed.

You can use one of starter templates:

Plunkr: https://plnkr.co/edit/0NipkZrnckZZROAcnjzB?p=preview

StackBlitz: https://stackblitz.com/edit/ngx-bootstrap?file=app%2Fapp.module.ts

Versions of ngx-bootstrap, Angular, and Bootstrap:

ngx-bootstrap:

Angular:

Bootstrap:

Build system: Angular CLI, System.js, webpack, starter seed:

NenadJovicic commented 4 years ago

I agree with this. When I want to send some data from modal to component that opened it, I always have to create some EventEmitter and then to subscribe on those events there should be a way to have some default listener bsModalRef.onClose(result => doSomething(result)) and in modal, when we want to close it, we can call bsModalRef.hide(data) and parent component can easily accept it