Trigger Angular Console Change Detection

In AngularJS, we managed to call the digest loop, getting the ng-app element with something like

var scope = angular.element(element).scope(); scope.$apply(...); 

I reviewed the solution for this in Angular (4+), but only found solutions that work in an application like ( Triggering Angular2 for manually detecting changes ). I need something that works from the console.

I am sure that I am doing it wrong, but trying to apply the answer to the above question did not help. I have tried many variations of this:

 ng.probe($0).injector.view.root.ngModule.injector.get('ApplicationRef') 
+9
source share
3 answers

I usually do this as follows in dev mode

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

enter image description here

+14
source

Solution 1:
1. Click the item (on which you want to enable change detection) in dev-tools. Tab items
ng.probe($0).injector.get(ng.coreTokens.ApplicationRef).tick()

Solution 2: Launch a specific component change detector
1. Click the item (on which you want to enable change detection) in dev-tools. Tab items
ng.probe($0).componentInstance.cdRef.detectChanges()

+3
source

@guati I received the error “Unable to load the module” (angle 7), the error was caused by some changes in the routing, but even when I canceled the changes, the error did not disappear (maybe the changes were not detected), so I just restarted the development server ( served the application again), and he left.

0
source

Source: https://habr.com/ru/post/1269354/


All Articles