3

I am having the following code:

var vocabularies = new MyDataService.myService();
vocabularies.success(function (data) {
     console.log(data);                                    
}).error(function (data) {
     console.log(data);
});

Where can I view the value of data instead of debugging the above code?

5
  • 3
    in console only.. :D rightClick-> inspect element.. and there you are... Commented Mar 16, 2016 at 7:20
  • in Chrome click on view area -> Inspect Element -> Sources Tab. Here u will find the sources Commented Mar 16, 2016 at 7:20
  • If you don't want to use the developer console, try using alert(data). Commented Mar 16, 2016 at 7:22
  • How to open the JavaScript console in different browsers? Commented Mar 16, 2016 at 7:27
  • In Angular Way!! docs.angularjs.org/api/ng/service/$log Commented Mar 16, 2016 at 7:31

2 Answers 2

3

If you want to view the data present in the console then you may use keyboard shortcut Ctrl + Shift + J to bring focus on the console. If you want to see your data during execution you may use alert instead of console.log.

If you want to bind your data to the HTML you need to use

    $scope.variable=data;

you can then get your value by using expression tag in HTML.

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

Comments

2

You can assign your data to a $scope variable. And on template you can view it. Find below code:

var vocabularies = new MyDataService.myService();
vocabularies.success(function (data) {
   console.log(data);
   $scope.viewData = data;                                    
}).error(function (data) {
  console.log(data);
  $scope.viewData = data;
});

And then on the template:

{{viewData | json}}

The above will print it in json format if its json else normal text

Comments

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.