How to debug on Ionic View [not the question, here's the answer!]

Hi,

I think that many of you have already heard of http://jsconsole.com

If not, it’s a service that can show the JS console entries remotely.

When you add their *.js script to your code, you can monitor the console via internet.

You must add the tag

<script src="http://jsconsole.com/remote.js?<<your_pass>>"></script>

to your <head> on the index.html file, where <<your_pass>> is anything you want.

Then, go to

http://jsconsole.com/?: listen <<your_pass>>

and run your app.

Everything that you put in console.log('text') should appear there, and now you can debug your app when using Ionic View.

Now you must have seen that the errors doesn’t appear!
To log the errors as well, surround your suspictious code with try and catch, and print the error object into the console, like:

try{
    //your code here
}catch(e){
    console.log(e);
    console.log(e.stack);
    console.log(e.line);
}

and now you can see what and where anything got wrong.

Hope to help you, and sorry for the bad english…!

Regards,
Jeff

9 Likes

This is so helpful, nice work!

Thanks for the article. I tried to follow your instructions and jsconsole worked great when I used ionic’s emulate and serve. However I could not get jsconsole to work on my ionic view app. Did you do something different for your ionic view?

1 Like

Hi @justinweathersby or anyone else,

did you get jsconsole to work in Ionic View? I am trying to debug something that is only happening in Ionic View (not nor serve).

Regards

Tom

Is this for Ionic 1 or Ionic 2?

1 Like

It works for both. It is framework agnostic.

This appears to be a dead project, I added the and nothing showed up in http://jsconsole.com/?:listen

I tried doing a get request to

As far as I can tell from the issues board this project is discontinued due to lack of funding.

Is there an alternate approach anyone can recommend?

I found this but it seems to be for old versions of ionic:
https://www.npmjs.com/package/ionic-debug-console

Thanks very much.

Will