当另一个控制器在 Angular 中加载 UI-bootstrap 时,如何停止调用模态实例?
How do I stop a modal instance from being called when a different controller loads with UI-bootstrap in Angular?
我已经为我的控制器实现了一种在特定时间后打开 ui-bootstrap 模式的方法。但是,如果我离开该页面,它仍会打开。这个想法是让模态仅在该特定视图上几分钟后打开。当加载不同的控制器时如何停止它?提前致谢。请让我知道是否需要任何其他代码uired.
这是打开该模式的代码:
$interval(function () {
var modalInstance = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'modal.html',
controller: 'ModalInstanceCtrl',
size: 'lg',
});
}, 120000, [1]);
您可能需要在路线或状态更改时使用 $interval.cancel(your_interval) 停止间隔,请参阅此 answer for "How to track route or state change?" and go through the $interval documentation $interval.cancel()。希望这能解决您的问题。
我已经为我的控制器实现了一种在特定时间后打开 ui-bootstrap 模式的方法。但是,如果我离开该页面,它仍会打开。这个想法是让模态仅在该特定视图上几分钟后打开。当加载不同的控制器时如何停止它?提前致谢。请让我知道是否需要任何其他代码uired.
这是打开该模式的代码:
$interval(function () {
var modalInstance = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'modal.html',
controller: 'ModalInstanceCtrl',
size: 'lg',
});
}, 120000, [1]);
您可能需要在路线或状态更改时使用 $interval.cancel(your_interval) 停止间隔,请参阅此 answer for "How to track route or state change?" and go through the $interval documentation $interval.cancel()。希望这能解决您的问题。