Availability of $ scope from the DOM in production?

According to this article (and several others), one of the most common mistakes a developer can make when using Angular:

Common Mistake # 1: Accessing a Domain Using the DOM

There are several optimization optimizations recommended for production. One of them disables debugging information.

DebugInfoEnabled is a parameter that defaults to true and allows access to the access area through DOM nodes. If you want to try this through the JavaScript Console, select the DOM element and access its scope using:

angular.element(document.body).scope()

This can be useful even if you are not using jQuery with your CSS, but should not be used outside the console. The reason is that when $ compileProvider.debugInfoEnabled is set to false, a call .scope()to the DOM node will return undefined.

However, when using Angular, there are certain points when a developer needs to access an area outside of angular.

Is there any other recommended way to return to scope?

+4
source share

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


All Articles