Angular Apply已经在进行中 [英] Angular Apply already in progress
本文介绍了Angular Apply已经在进行中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用一个名为intro.js的有角js插件.可以在此处找到.我要执行的操作是在用户单击演示按钮时打开一个下拉列表,以便我可以显示该下拉列表项目的一些介绍步骤.这是我的html:
I am using an angular js plugin called intro.js. It can be found here. What I want to do with this is open up a dropdown when the user clicks on the demo button so that I can show some intro steps for the dropdown items. Here's my html:
<body ng-controller="MainCtrl as ctrl">
<div ng-intro-options="ctrl.IntroOptions"
ng-intro-method="ctrl.CallMe">
<div class="container">
<button class="btn btn-success"
ng-click="ctrl.startHelp()">Help</button>
</div>
</div>
</body>
还有我的JS:
MainCtrl.prototype.startHelp = function() {
var _this = this;
angular.element('#drop-down-button').trigger('click');
_this.CallMe();
};
我也尝试过
angular.element('#drop-down-button').click();
但是同样的错误.如果我删除 angular.element
行,该简介工作正常.但是,在包含该错误的情况下,我会收到此错误.知道如何解决这个问题吗?
But the same error. The intro works just fine if i remove the angular.element
line. However, with that included I get this error. Any idea how to get around this?
推荐答案
我只需要将调用包装在超时内即可.
I just had to wrap the call inside of a timeout.
MainCtrl.prototype.startHelp = function() {
var _this = this;
_this.$timeout(function() {
angular.element('#drop-down-button').trigger('click');
}, 0, false);
_this.CallMe();
};
这篇关于Angular Apply已经在进行中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文