How to debug angular applications efficiently? Part — III
ng.getInjector
Usage: ng.getInjector(document.querySelector(“Your element selector”));
This API will return the element injector of the queried element. The returned object contains pretty much information or more like metadata of the element queried.
This element injector encloses the module injector in closure form, so we cannot access the module injector in the console.
Element injector shares two properties lview and tview. Lview contains the necessary data like type, input, output, directives applied, view queries, parent components, and the contexts that belong to the element, tview contains the respective indices, and each and every element will have its own element injector.
Each element injector will have a parent injector, If an object is requested it will traverse up the hierarchy to get the object if the same is not found in its injector. For element injector hierarchy and angular dependency resolution mechanism, please refer to the following link,
ng.applyChanges
Usage: ng.applyChanges(document.querySelector(“Your element selector”));
This API doesn’t return anything but it triggers the change detection for the application. The element selector should be a component.
It will query the root component or bootstrapped component and triggers the change detection from the top.