1

I'm trying to debug my angular2 app with source map by placing a breakpoint in the .ts file.

foo(){
   //breakpoint here
   console.log('bar');
 }

the breakpoint only gets hit when loading that component and not when executing. any idea?

Joe B
  • 738
  • 7
  • 28

3 Answers3

0

put debugger; in the line where ever you want.browser will definitely pauses;

RamiReddy P
  • 1,628
  • 1
  • 18
  • 29
0

Not sure if you still need an answer, but assuming you're doing something like this, I believe angular runs some code only once (like constructors / initialization ... etc).

If the break point is only getting hit once, it is probably because angular intends for that. Try putting your breakpoint in a method that you know for sure gets called multiple times. Try to figure out [where your code is](https://angular.io/docs/ts/latest/guide/architecture.html#!#components in the bigger picture of the architecture of an angular app.

Otherwise, would need more context/info to properly answer.

Sean Newell
  • 1,033
  • 1
  • 10
  • 25
0

Closing and opening the browser, solved my issue.

Dev_FullStack
  • 33
  • 1
  • 8