2017-10-10 87 views
2

我在Ionic应用程序中收到TypeScript错误。我有一个sidemenu应用程序,并将菜单分成它自己的组件,以便我可以更轻松地添加登录页面。我一直在关注这个指南可以这样做:http://roblouie.com/article/344/ionic-2-hide-menu-or-tabs-for-login-screen/Ionic新增功能:App.Component.Ts中的Typescript错误

在我的新app.component.ts我有以下代码:

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(); 
    }); 
    } 
} 

我与离子相当新的,我一直主要是以下指南开始。任何有关此事的建议将不胜感激。以下是错误消息我得到:

Error Message

enter image description here

回答

3

使用如图所示的构造(DI)角内喷射,而不是StatusBar的静态方法和SplashScreen类,实例如下:

initializeApp() { 
    this.platform.ready().then(() => { 
     this.statusBar.styleDefault(); 
     this.splashScreen.hide(); 
    }); 
}