Я пытаюсь внедрить NavController в мой app.component.ts, но у меня постоянно появляется сообщение об ошибке:
NullInjectorError: No provider for NavController!
Я все делаю правильно, импортируя и декларируя это, как и с любым другим компонентом, который я добавляю. Но на моем главном компоненте приложения это, похоже, не нравится.
Что там происходит?
код:
import { AuthenticationProvider } from './../providers/authentication/authentication';
import {Component} from '@angular/core';
import { Events, Platform, NavController } from 'ionic-angular';
import {StatusBar} from '@ionic-native/status-bar';
import {SplashScreen} from '@ionic-native/splash-screen';
import {ScreenOrientation} from '@ionic-native/screen-orientation';
import {TabsPage} from '../pages/tabs/tabs';
import {LoginPage} from "../pages/login/login";
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage: any = TabsPage;
constructor(
platform: Platform,
statusBar: StatusBar,
splashScreen: SplashScreen,
events: Events,
private navCtrl: NavController,
private authProvider: AuthenticationProvider,
screenOrientation: ScreenOrientation) {
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.styleLightContent();
splashScreen.hide();
//device-specific code, such as detecting screen rotation
if (platform.is('cordova')) {
screenOrientation.lock(screenOrientation.ORIENTATIONS.PORTRAIT);
}
events.subscribe('user:expired_token', () => {
this.rootPage = LoginPage;
});
});
}
logout(){
this.authProvider.logout();
this.navCtrl.setRoot('LoginPage');
}
}