Patrick Patrick - 1 year ago 98
jQuery Question

Execute function when modal is closed (Plunker attached)

I have a minor bug which i am not able to fix. Here is the plunker->

When the user opens the modal and makes selection, he chooses to close the modal by pressing 'Ok'

At this point of time, i want to execute ExecOnModalClose() function mentioned in the controller.

So, here is the code i tried.

$scope.ok = function() {

Execute this function below when user presses 'Ok' as shown above.

$scope.ExecOnModalClose = function() {
console.log("Execute this after modal closes on pressing Ok");

Can someone please let me know how to link these two.

Answer Source

You can use

<button class="btn btn-primary" type="button" ng-click="ok(); ExecOnModalClose()">OK</button>


after the change of the original plunker, using broadcasting seems to be the working solution:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download