AngularUI引导模态Open事件 [英] AngularUI Bootstrap Modal Open event

查看:219
本文介绍了AngularUI引导模态Open事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过一个链接调用一个引导模式对话框。

我要当弹出对话框,开始在角控制器的计时器。如何检测对话框打开事件的角度控制器启动计时器?

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

  app.controller('myctrl',
    ['$范围,$窗口','$超时,SVC,
    功能($范围,$窗口,$超时,SVC){        $ scope.countdown = 10;        $ scope.runCounter =功能(){
            $ scope.countdown - = 1;
            如果($ scope.countdown大于0)
                $超时($ scope.runCounter,60000);
       }
        $ scope.runCounter();
    }]);

定时器启动应用程序启动时。我想对话框打开时计时器才开始。
谢谢你。


解决方案

 警报($('#myModal')hasClass(IN));

如果模式是开放的,它将返回true。您可以检查模式窗口是否打开或不那么在哪里开始你的倒数活动。

I'm invoking a bootstrap modal dialog through a link.

I want to start a timer in the angular controller when the dialog pops up. How do I detect the dialog open event in the angular controller to start the timer?

If I start timer in the scope like this,

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();
    }]);

the timer starts when the application starts. I want the timer to start only when the dialog opens. Thanks.

解决方案

alert($('#myModal').hasClass('in'));

It will return true if modal is open. You can check whether Modal window is open or not then u can start your countdown event..

这篇关于AngularUI引导模态Open事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆