Search code examples
angularjslaravel-5.3

reload data in modal after another modal close angularjs


So the issue is here, I have a modal and another modal.

the first modal has a table which is to be filled by the other modal but it doesn't update the view.

first modal

another modal

but when I close all modals then open it again the values are changed to what I saved.

My Question is how to refresh or reload the data in table not the modal after saving the other modal by using angularjs and without closing all modals please help.


Solution

  • You can:

    • 1)

      If your modals are components, you can add pass bindings to it.

    • 1a)

      Both modal may use 2-way data binding to work on the same object (not recommended)

    • 1b)

    You can use bindings '<' (one-way) and '&(expression) for callback. On modal can trigger the callback to update the data in the parent and the parent will push it to second modal via '<' binding

    • 2)

      You can make a angular service for communication and where: modal A registers hist callback function and modalB will call a service moethod which will trigger modal A callback. Something like publish subscribe pattern

    • 3)

      You can try to hack it with $scope.parent.$apply() called from one of modals, so it will recalculate all the stuff from it's parent