加载时的Bootstrap-angular-ui模态 [英] Bootstrap-angular-ui modal on load

查看:68
本文介绍了加载时的Bootstrap-angular-ui模态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为网站使用 bootstrap-angular-ui-modal 我正在努力。我用来打开模态的代码

I am using bootstrap-angular-ui-modal for a site I am working on. The code I am using to open the modal

$modal.open(
    {
        templateUrl: '/home/template',
        controller: myCtrl,
        resolve: {
            data: function () {
                return data;
            }
        }
    });

一切正常。但我需要找到一种方法来加载模态后执行一些代码。我尝试过不同的东西,却无法让它们发挥作用。我试过的一些事情

Everything is working fine. But I need to find a way to execute some code after modal is loaded. I tried different things but can't make them work. Some of things I tried

在模板中我做了

<script>
    document.onload = function () {
        console.log('opened');
    };
</script>

我还发现有一个名为openned的角度模态对象的承诺。我试图

I also found there is a promise for the angular modal object named openned. I tried to

modalInstance.opened.then(function(){console.log('hello')});

也不工作。我可以在这里使用一些帮助。

not working either. I can use some help here.

推荐答案

这绝对不是一个好的解决方案,但至少对我有用。我刚刚在执行所需函数之前添加了超时,

This is definitely not a good solution, but at least worked for me. I just added a timeout before executing the desired function,

modalInstance.opened.then(
    $timeout(function() {
            console.log('hello');
        }, delay));

这篇关于加载时的Bootstrap-angular-ui模态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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