0

I have implemented a way for my controller to open a ui-bootstrap modal after a specific time. However if I navigate away from the page it will still open. The idea is for the modal to only open after a few minutes on that specific view. How do I stop it when a different controller loads? Thanks in advance. Please let me know if any other code is required.

Here is the code to open that modal:

$interval(function () {
        var modalInstance = $uibModal.open({
            animation: $scope.animationsEnabled,
            templateUrl: 'modal.html',
            controller: 'ModalInstanceCtrl',
            size: 'lg',
        });                             
}, 120000, [1]);
Poot87
  • 105
  • 9

1 Answers1

0

You might need to stop interval using $interval.cancel(your_interval) on route or state change please see this answer for "How to track route or state change?" and go through the $interval documentation $interval.cancel(). Hope this will solve your problem.

Community
  • 1
  • 1
Shubham Takode
  • 525
  • 8
  • 24