Trigger Angular change detection from console

前端 未结 3 1979
北海茫月
北海茫月 2020-12-08 16:42

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.$         


        
3条回答
  •  时光取名叫无心
    2020-12-08 17:20

    I usually do it as follows in dev mode

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

    Starting with Angular 9 with Ivy you can call:

    ng.applyChanges(ng.getComponent($0))
    

    Where $0 points to component's element

提交回复
热议问题