Why do people initialize data in the constructor?

Even in the Ionic docs I see examples where they initialize data in the constructor, like so:

export class AppComponent {
    private platform: Platform,
    private splashScreen: SplashScreen,
    private statusBar: StatusBar,
    private authService: AuthenticationService,
    private router: Router
  ) {

  initializeApp() {
    this.platform.ready().then(() => {

      this.authService.authenticationState.subscribe(state => {
        console.log("Auth state: " + state);
        if (state) {
        } else {

It is my understanding that it’s a good practice to initialize data in the ngOnInit lifecycle method instead, but still I see time and time again that in Ionic apps people initialize data in the constructor.

Why in the example above the author would choose to use the authService in the constructor? I think it would be better in the ngOnInit method no?

Depending on livecyle some things are done/avaialable. For example elements fetched by @Viewchild are in constructor not available. You need a later livecyle. So if you put your code in ngonInit, then you are sure that

ngOnInit() Initialize the directive/component after Angular first displays the data-bound properties and sets the directive/component’s input properties.

Called once , after the first ngOnChanges() .

In this example initializeApp calls a promise. A promise execude the code asyncrounous in the future, but you do not know when.

Best regards, anna-liebt