In the scenario of having an angularJS application, the importance of not manipulating the DOM through a service or controller is clear. Instead, using a directive for such manipulations is recommended. But what if the desired modification lies outside the scope of the angular app?
For instance, consider the need to access the BODY tag and disable scroll bars on it. Writing a directive becomes challenging since the ng-app
directive is nested deep inside a div
, making the BODY tag inaccessible.
How can one address this issue effectively? After reading this informative blog post, it appears that performing DOM manipulations via a service might be acceptable. What then, is considered the best practice for accessing DOM elements, particularly those lying beyond the reach of an angularJS application?