To use console.log in Angular first the configuration has to be changed.
If you use TSLint or ESLint, the console log setting has to be enabled.
In TSLint, in no-console change true to false.
By default, tslint.json will look like this,
"rules": {
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
}
After change,
"no-console":[
false
]
In ESLint rule, make the no-console to off. There should be a .eslintrc.js or .eslintrc.json file to enable console log.
.eslintrc.js
{
"rules": {
"no-console": "off"
}
}
Keep console.log in .ts file and run the application.
Below code shows a method in typescript file with console.log,
submit() {
console.log('Form Status:'+this.reactiveForm.status);
if(this.reactiveForm.status === 'VALID'){
console.log(this.reactiveForm.value);
}
}
In browser right click the mouse cursor and click Inspect (Ctrl+Shift+I) or click F12 key.
In this way you can debug the Angular application in Browser console.