2

I'm trying to debug a $http problem in our app and when I step into $http.get the debugger doesn't show the value of any AngularJS local variables. Hover shows nothing and right click 'Evaluate in console' throws Uncaught ReferenceError: url is not defined

Is there someway to see the values of variables inside AngularJS during debugging?

Thanks.

[Edit for Bruno] This is the code where context is lost, (angular.js (1.4.8)):

function createShortMethods(names) {
   forEach(arguments, function(name) {
      $http[name] = function(url, config) {
         return $http(extend({}, config || {}, {
            method: name,
            url: url
         }));
      };
   });
}

Stepping into $http.get (above) neither url nor config have values in the debugger. url probably has a value as the REST API is accessed over the network.

Tried Batarang, it does not want to work with Angular 1.4.8

[Update] Looks like this is related to Angular's use of strict mode, I'll have to work around that.

Thanks to everyone for their time & thoughts.

8
  • It'll be easier to get help if you show the problematic piece of your code (controller + view), including the line where you set the break point. Commented Nov 24, 2015 at 17:02
  • Doubtful, it's a problem with Chrome Developer Tools debugger and Angular, but here you go. Commented Nov 24, 2015 at 17:03
  • I don't follow. If I step into $http.get and url and config are function parameters I should be able to inspect their values in the local (function) context. That is, url and config are in the current stack frame. Commented Nov 24, 2015 at 17:13
  • Possible duplicate: stackoverflow.com/questions/18782069/… Commented Nov 24, 2015 at 17:27
  • @Bruno, not a duplicate, other SO questions of this nature are about debugging applications using Angular, this question is about debugging AngularJS itself (inside AngularJS). The problem is that Angular declares strict which disables looking at local variables inside Angular. Commented Nov 24, 2015 at 19:19

2 Answers 2

0

You can try AngularJS Batarang. It is for debugging angular applications. ng-inspector for AngularJS can also help you.

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

Comments

0

You can add a breakpoint before the $http.get(XXX)and then in the Chrome's console you can inspect variables by writing their names.

2 Comments

The problem I'm trying to debug is inside Angular, I really need visibility.
have you checked the value of the url variable? if you write $http it return the $http function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.