Reputation: 23
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?
Upvotes: 1
Views: 589
Reputation: 48968
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
Upvotes: 0
Reputation: 707
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
Upvotes: 3