[英]How to call $modal.open in Ui-Bootstrap 0.10.0 from controller in angularjs
[英]How do I stop a modal instance from being called when a different controller loads with UI-bootstrap in Angular?
我為控制器實現了一種在特定時間之后打開ui-bootstrap模態的方法。 但是,如果我離開該頁面,它將仍然打開。 這個想法是模態只能在該特定視圖上打開幾分鍾后打開。 加載其他控制器時如何停止? 提前致謝。 請讓我知道是否需要其他代碼。
這是打開該模式的代碼:
$interval(function () {
var modalInstance = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'modal.html',
controller: 'ModalInstanceCtrl',
size: 'lg',
});
}, 120000, [1]);
您可能需要在路線或狀態更改時使用$ interval.cancel(your_interval)來停止間隔,請參閱此答案以獲取“如何跟蹤路線或狀態更改?” 並瀏覽$ interval文檔 $ interval.cancel()。 希望這能解決您的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.