When I trying to import NavController
I’m receiving strange error:
Error in ./MyApp class MyApp_Host - caused by: No provider for
NavController!
My code:
import { Component, ViewChild } from '@angular/core';
import { Events, Platform, Nav, NavController } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';
import { Storage } from '@ionic/storage';
// Pages
import { HomePage } from '../pages/home/home';
import { LoginPage } from '../pages/login/login';
// Providers
import { User } from '../providers/user';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage: any = HomePage;
@ViewChild(Nav) nav: Nav;
constructor(
private platform: Platform,
private events: Events,
private storage: Storage,
private User: User,
private navCtrl: NavController
) {
platform.ready().then(() => {
StatusBar.styleDefault()
User.isLogged().then(is_logged => {
if (is_logged == false) {
this.rootPage = LoginPage
}
Splashscreen.hide()
})
})
}
listenToLoginEvents() {
this.events.subscribe('user:login', () => {
// this.navCtrl.push(HomePage)
// this.navCtrl.setRoot(HomePage);
})
this.events.subscribe('user:logout', () => {
console.log('user:logout')
})
}
}