I'm fairly new to both Angular2 and typescript. Given that typescript is a superset of javascript, I assumed that functions like console.log
would function as expected. Interestingly, console.log
works perfectly in .ts
files when placed outside a component class, but it doesn't behave as anticipated when utilized from within the component class.
// main.ts
import { Component } from '@angular/core';
console.log("Hello1"); //1. This works perfectly
@Component({..)
export class App {
s: string = "Hello2";
// console.log(s); //2. This gives compilation error (when uncommented)
// Error: Function implementation is missing or not immediately following the declaration.
}
Could there be something important that I'm overlooking?