shlomiassaf / ngx-modialog

Modal / Dialog for Angular
http://shlomiassaf.github.io/ngx-modialog
MIT License
686 stars 242 forks source link

Run a function when a button is clicked #159

Closed invot closed 8 years ago

invot commented 8 years ago

Currently I don't see a way to run a function once a button is pressed in a model window. However, say I want to confirm that a user intends to do an action, I'd like to be able to run something when they confirm.

Currently, there doesn't appear to be a way to do that.

shlomiassaf commented 8 years ago

You can do it with the beforeDismiss() / beforeClose() hooks.

This requires using a custom modal.

You can return a boolean or Promise<boolean>.

see https://github.com/shlomiassaf/angular2-modal/blob/master/src/demo/app/bootstrap-demo/bootstrap-demo-page/custom-modal-sample.ts#L69-L75

shlomiassaf commented 8 years ago

If you want to do it using the built in presets with a built in plugin (e.g: confirm with bootstrap) you will have to build a custom plugin for that inheriting 99% of the code from the plugin.

This is an expected behaviour, you are changing the modal and it's behaviour.

shlomiassaf commented 8 years ago

I'll close this stale issue, please re-open with a comment if it still an issue.