我試圖根據我在$ 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