我试图根据我在$ digest中为$ scope变量所做的更改来更新我的视图,在对我的变量进行必要的更改后,我调用了$ scope。$ apply(),这实际上导致了一个异常,表示$ scope。$ apply已经在执行中。有人可以帮助我如何解决这个问题。在你的代码
this.showCart = false;
/*This function is called from the view on a ng-click*/
this.addCart=function(){
if (this.showCart === false) {
this.showCart = true;
this.hideEmptyCart = 'none';
this.showFullCart = 'initial';
this.searchRightMargin = 40;
this.updateWidth();
$scope.$apply();
}
}
此错误通知您$ scope。$ apply已在进行中。你不需要明确地调用它。你可以发布一些代码吗? – Corey 2015-03-30 21:31:09
感谢Corey的回复,我用一些代码更新了帖子。 – 2015-03-30 21:35:23
你不需要调用'$ scope。$ apply()'。把它拿出来,一切都应该工作。 – 2015-03-30 21:35:34