我正在使用 bootstrap-angular-ui-modal对于我正在处理的网站。我用来打开模态的代码
$modal.open(
{
templateUrl: '/home/template',
controller: myCtrl,
resolve: {
data: function () {
return data;
}
}
});
一切正常。但是我需要找到一种方法来在加载模态后执行一些代码。我尝试了不同的东西,但无法使它们起作用。我尝试过的一些事情
在我做的模板中
<script>
document.onload = function () {
console.log('opened');
};
</script>
我还发现名为 openned 的 Angular 模态对象有一个 promise 。我试过
modalInstance.opened.then(function(){console.log('hello')});
也不行。我在这里需要一些帮助。
最佳答案
这绝对不是一个好的解决方案,但至少对我有用。我只是在执行所需功能之前添加了一个超时,
modalInstance.opened.then(
$timeout(function() {
console.log('hello');
}, delay));
关于javascript - 加载时的 Bootstrap-angular-ui 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19657323/