2

I am getting a TypeScript Error in my Ionic app. I have a sidemenu app, and was separating the menu into it's own component so that I could add a login page more easily. I have been following this guide to do so: http://roblouie.com/article/344/ionic-2-hide-menu-or-tabs-for-login-screen/

In my new app.component.ts I have the following code:

import { Component, ViewChild } from '@angular/core';
import { Nav, Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { MenuComponent } from "./menu.component";

@Component({
  template: '<ion-nav #baseNav></ion-nav>'
})
export class MyApp {
  @ViewChild('baseNav') nav: Nav;

  constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen) {
    this.initializeApp();
  }

  ngOnInit() {
    this.nav.push(MenuComponent, { animate: false });
  }

  initializeApp() {
    this.platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      SplashScreen.hide();
    });
  }
}

I am fairly new with Ionic and I have been mostly following guides to get started. Any advice on the matter would be greatly appreciated. Here is the error message I am getting:

Error Message

enter image description here

1 Answer 1

3

Use the instances that Angular injects in the constructor (DI) instead of the static methods of the StatusBar and the SplashScreen classes, as shown below:

initializeApp() {
    this.platform.ready().then(() => {
        this.statusBar.styleDefault();
        this.splashScreen.hide();
    });
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.