I have the following html:
I am trying to get the scope like:
console.log("app element scope: " + $('#angularHeaderDiv').scope());
but I received: undefined
.
I am angularJS beginner and I simply dont' get why this doesn't work.
UPDATE: This doesn't work either:
var appElement = document.getElementById('angularHeaderDiv');
console.log("app element scope: " + angular.element(appElement).scope());
UPDATE 2: All the code where I try to print out the scope in console:
angular.module('cmApp', [ 'pascalprecht.translate' ])
.config(function($translateProvider) {
$translateProvider.useStaticFilesLoader({
prefix : '/resources/angular/scripts/languages/locale-',
suffix : '.json'
});
// add translation table
$translateProvider.preferredLanguage('en');
var appElement = document.getElementById('angularHeaderDiv');
console.log("app element: " + angular.element(appElement).scope());
});
If you have this in your code:
$compileProvider.debugInfoEnabled(false);
...then scope()
and isolateScope()
will return undefined
. If it's set to false
, you'll notice other things like ng-scope
and ng-isolate-scope
disappearing out of class=
attributes on elements.
See: https://code.angularjs.org/1.3.16/docs/guide/production#disabling-debug-data
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With