1

I know I can enable $compileProvider to see debug info, but in my case, I prefer not to enable it.

When I use angular.element($0).scope(); or $($0).data().$scope it is returning undefined. I wonder if there is any solution that doesn't need to turn on debug info to get $scope with jQuery.

Mistalis
  • 17,793
  • 13
  • 73
  • 97
Mohammad Hossein Amri
  • 1,842
  • 2
  • 23
  • 43
  • Possible duplicate of [AngularJs scope variables in console](https://stackoverflow.com/questions/29799494/angularjs-scope-variables-in-console) – Estus Flask Aug 28 '17 at 12:15

2 Answers2

1

First you need to select the element from developer mode then go with console in browser.: Before this it must be ensure that your angularjs library loaded.

angular.element($0).scope()
Kunvar Singh
  • 1,779
  • 2
  • 13
  • 21
0

$0 is a reference to the select element of the DOM. You probably gets undefined because you didn't select an element of the DOM before asking for its scope.

There is two ways to do it:

  • Right click + inspect an element, then run angular.element($0).scope();
  • Get the element from its ID directly in the console: angular.element(document.getElementById('elementId')).scope();
Mistalis
  • 17,793
  • 13
  • 73
  • 97