0

I'm using angular-ui-router-uib-modal and I have a question on it.
When I close my modal (which confirm a successfull/failed operation), I need to reload page below (that show a list of data). As shown in the example below, I can specify that behavior in 'Close' button and also in 'X symbol' to close modal (with the ui-sref-opts="{reload: true}").
But... How can I specify the same operation when a user clicks outisde the modal and automatically closes the modal itself?

<div class="modal-content">
    <div class="modal-header">
        <div class="bb8-modal-close" ui-sref="home.gestioneFondi({gestione:true, innescatoDaMenuLaterale:false})" ui-sref-opts="{reload: true}">
            <span class="visuallyhidden glyphicon glyphicon-remove-circle"/>
        </div>
        <h4 class="modal-title modal-title-font">Info</h4>
    </div>
    <div class="modal-body" ng-switch="esito">
        <p class="text-center modal-body-font" ng-switch-when="true">Success</p>
        <p class="text-center modal-body-font" ng-switch-when="false">Error</p>
    </div>  
    <div class="modal-footer">
        <button class="btn btn-primary" ui-sref="home.gestioneFondi({gestione:true, innescatoDaMenuLaterale:false})" ui-sref-opts="{reload: true}">Chiudi</button>
    </div>
</div>


Thank you for any help

zgue
  • 3,793
  • 9
  • 34
  • 39
Raul
  • 115
  • 5
  • 16
  • I find an answer seeing this post (and the Malcor's reply https://stackoverflow.com/questions/42416570/how-to-handle-possibly-unhandled-rejection-backdrop-click-in-a-general-way) – Raul Mar 13 '18 at 11:32

1 Answers1

0

So when you open a modal like this it is returning the promise:

var modalInstance = $modal.open({..});

you can specify the modal closing event on the promise

modalInstance.result.then(function (result) {..});

You can specify below code to reload the state.

$state.reload();

For above to work, you have to inject $state dependency in your controller.

app.controller('controller', ['$state',function($state){..}])

Pratik Pambhar
  • 184
  • 1
  • 7