从控制台触发角度变化检测 [英] Trigger Angular change detection from console
本文介绍了从控制台触发角度变化检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在AngularJS中,我们可以通过使用类似
In AngularJS we were able to trigger a digest cycle by getting the ng-app element with something like
var scope = angular.element(element).scope();
scope.$apply(...);
我一直在寻找在Angular(4+)中做到这一点的解决方案,但只发现了可以在应用程序中工作的解决方案,例如(
I have looked all over for a solution to do this in Angular(4+) but have only found solutions that work in the app like(Triggering Angular2 change detection manually). I need something that works from the console.
我确定我做错了,但是尝试对上述问题应用答案无效.我尝试了许多变体:
I'm sure I'm doing it wrong but trying to apply the answer on the above question didn't work. I tried many variations of this:
ng.probe($0).injector.view.root.ngModule.injector.get('ApplicationRef')
推荐答案
我通常在开发人员模式下执行以下操作
I usually do it as follows in dev mode
ng.probe(getAllAngularRootElements()[0]).injector.get(ng.coreTokens.ApplicationRef).tick()
这篇关于从控制台触发角度变化检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文