Trigger change detection in Angular IVY application

廉价感情. 提交于 2020-01-16 12:01:27

问题


Before IVY, we could trigger change detection like this, based on this awesome SO answer:

ng.probe(getAllAngularRootElements()[0]).injector.get(ng.coreTokens.ApplicationRef).tick()

The question now is, how do we achieve this in Ivy?

When running in dev mode, and typing ng in the console reveals this:

But I am unsure how to use this to detect changes in the root element?

workaround

By injecting the ChangeDetectorRef in a given component, i can do the following (where $0 is the previously selected element in the dev tools):

ng.getComponent($0).changeDetectorRef.detectChanges()

But this is not for the root component?


回答1:


You can call

ng.markDirty($0)

Where $0 is the selected element in the devtools panel.



来源:https://stackoverflow.com/questions/59191406/trigger-change-detection-in-angular-ivy-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!