Debugging Two ways, to see the content of an scope var (Mini-challenge 5) Answer

Check out Mini-challenge 5 Instructions

Answer:
Debugging Two ways, to see the content of an scope var (Mini-challenge 5) Answer

To answer this challenge we going to show to ways to see the content of a variable in the scope when debugging an AngularJs application.

One way to do it is using the Angular JSON filter in the view, this will print the content of the variable:

<div>{{vm | json}}</div>

The other way to do it, is writing the following code in the browser developer console:

angular.element($('#main')).scope()

where $(‘#main’) is an element inside of the controller that you want to see the variable’s content. See a working example below.

If you have a solution for this challenge, different from the proposal solution on this post, don’t be shy and share it with us. 🙂