I'm a newbie in the Angular space. I've been having trouble debugging my code. Any methods proven more effective in debugging Angular?
To start a debugging session, hit the F5 key or click RUN>START DEBUGGING and a terminal will open which will begin serving your web app, and a browser window will also open. Now if you add a breakpoint to your application code, you will be able to step through the code.
You can find the JavaScript Debugger under the sources tab of the ChromeDev Tools. As you look for bugs in your Angular code, this tool allows you to set breakpoints and inspect your code at runtime. It also gives you the capability to obtain the value of your variables at different points in time.
open the developer console in the chrome browser, this allows you to:
general tipps:
{{anImportantVariable | json}}
into html often is enough to debug stuff.and the most important: if everything looks ok, and it still does not work, the problem is in 99%:
ngShow
directive in JS is ng-show
in HTML, and isOpen
attribute in JS is is-open
in HTML)When it comes to inspecting the state: even though I always (irony) write unit tests for each and every conditional in my code (so I normally don't need to debug stuff) this is so far my favourite technique:
<pre ng-show='mymodel.debugPlz'>{{ mymodel.something | json }}</pre>
Simple example : fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With