Ionic 2 – Debugging your app

Hi Friends,

This is a response post to many of our friends asking me how to debug our apps. To be honest, I din’t look into this much and followed the traditional method (which was a big headache as the app became large). One of our friends J Glaser contacted me and instructed me on a new method which would make debugging much easier using the google chrome browser debugger.

A big thanks to our friend J Glaser who helped me with this debugging technique.

Let’s begin.

A video screencast of this post

First let’s scaffold out an Ionic 2 app using the below command.

(I am using ionic cli version 2.1.8).

Now just give ionic serve and open up your app in a chrome browser.

Open up the inspector(Ctrl + Shift + I) and click on sources. You would see a screen like this.


Now as you could see in the directories on the file tree left side you wouldn’t be able to see the ts files. This is due to the fact that the ionic_source_map is set to the value eval. Let’s change it.

Before that let’s make our app do something. Open up home.html and add the below code in between <ion-content> tags.

Open up home.ts and add the below code.

Now what we have done is very simple. We just have a button which when clicked will increment the value of a variable.

Now open up package.json and add this variable.

Now give ionic serve and open up your browser inspector again.

You will see the files are now available under a directory called debugging.


Now that you have the ts files available. You can debug using the debug tools available on the right side just like you do in any IDE debuggers.


You can set breakpoints, conditional breakpoints, skip statements, break out of functions all that stuff.

Hope this helped you guys. Thanks for reading. Peace.. :)


Liked it? Take a second to support admin on Patreon!