Angular2: Why isn't my component's console.log not logging anything

Viewed 23954

This is my component's code, non of the versions do anything. I just get blank console in browser.

export class AssetsComponent {
    s = 'Hello2';
    constructor() {
        this.s = 'ds';
        console.log(this.s); <--- nothing
        console.log('test'); <--- nothing
        console.log(s); <--- breaks the compiler
    }
}
4 Answers

The possible cause can be eslint, which just doesn't compile the console.log to javascript bundle. Use this exception for to disable it for the entire file:

/* eslint-disable no-console */

I had the same problem after trying to figure this one out for far too long on Safari, so here is my solution. Make sure your console output is set to All.

Safar Console Output Setting

Related