Reputation:
I have been trying to debug an Angular project with console.log()
, and I checked my chrome console logging options and made sure that all the levels are enabled, but I still got nothing as an output.
I placed my console.log()
in many places in the code, including at the constructor of a class and it still didn't work. I noticed; however, that I get an output at the chrome console when I change console.log()
to console.error()
. Any idea how to fix this problem?
Upvotes: 0
Views: 6519
Reputation: 8125
It may possible, Logging level has been enabled. You can look for below given code to disable it.
if (environment.production) {
enableProdMode();
}`
There might chance, log is disabled on lint
level. When u disable in lint level, on run of ng lint --fix
. It remove lower log level. Check your tslint config
for more info.
ng lint --fix
More info: Stripping all comments and console.logs with ng build --prod, possible?
Upvotes: 0
Reputation: 101
Just try with a hard-coded string in console.log like "console.log("something") and check if it printing. Otherwise, you can also place "debugger" in your code where you want to pause your application. Using this will ensure that whether the control is actually going in that block of code or not. After that press F12 and run your application.
Upvotes: 3