gpt4 book ai didi

angularjs - AngularUI Bootstrap 模态打开事件

转载 作者:行者123 更新时间:2023-12-03 14:26:48 25 4
gpt4 key购买 nike

我正在通过链接调用 Bootstrap 模式对话框。

当对话框弹出时,我想在 Angular Controller 中启动一个计时器。如何检测 Angular Controller 中的对话框打开事件以启动计时器?

如果我在这样的范围内启动计时器,

app.controller('myctrl',
['$scope', '$window', '$timeout', 'svc',
function ($scope, $window, $timeout, svc) {

$scope.countdown = 10;

$scope.runCounter = function () {
$scope.countdown -= 1;
if ($scope.countdown > 0)
$timeout($scope.runCounter, 60000);
}
$scope.runCounter();
}]);

计时器在应用程序启动时启动。我希望计时器仅在对话框打开时启动。
谢谢。

最佳答案

查看this出去。

var modalInstance = $modal.open({...});
modalInstance.opened.then(function() {
alert("OPENED!");
});
$modal.open()返回一个对象,该对象除其他属性外还包含 opened promise ,如上使用。

关于angularjs - AngularUI Bootstrap 模态打开事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19999501/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com