1

I just started learning angular js. I have understanding that we can access and debug scope available to any dom element by selecting/inspecting anywhere on the page and running

angular.element($0).scope()

code on console. But if you try this, I find its value undefined. How they are hiding it and how can I reach to data through console?

1
  • Load angular.js instead of angular.min.js. You will get better stack traces and data debugging will be enabled. Commented Feb 18, 2020 at 19:02

2 Answers 2

3

Its likley that debugInfoEnabled in $compileProvider is set to false, which means angular.element($0).scope() will always return undefined

You can however run angular.reloadWithDebugInfo in the console which will override this.

Reference:

AngularJS $compileProvider Documentation

AngularJS reloadWithDebugInfo Documentation

Sign up to request clarification or add additional context in comments.

1 Comment

angular.reloadWithDebugInfo is a life-saver if you don't have access to the source files ! thanks for the tip 🙏
0

Load angular.js instead of angular.min.js. You will get better stack traces and data debugging will be enabled.

From the Docs:

angular.element — jQuery/jqLite Extras

AngularJS also provides the following additional methods and events to both jQuery and jqLite:

  • scope() - retrieves the scope of the current element or its parent. Requires Debug Data to be enabled.

AngularJS angular.element API Reference - jQuery/jqLite Extras

For more information, see

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.