One thing I've noticed is that the <app-root>
component in Angular doesn't implement OnInit like all the other components. It may sound silly, but let's say I wanted to add a simple console.log('Hello World')
statement to display every time the app-root component is loaded (just for illustrative purposes), where should I place this code and does it require a specific function name (e.g. ngOnInit()
)? Or is the main purpose of angular to simply act as a wrapper that initializes other components.
Below is the basic structure as set up by the Angular CLI:
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
}