i started an ionic 2 app from the sidemenu starter. Now i want to move the code generated into the app component (the menu) into a folder and write a home component instead. When i run the app it shows me this error:
ORIGINAL EXCEPTION: No provider for NavController!
The code for my app.component is:
import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';
import { StatusBar } from 'ionic-native';
import { Login } from '../pages/login/login';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
nav: NavController;
constructor(public platform: Platform, nav: NavController) {
this.nav = nav;
this.initializeApp();
}
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();
});
}
registerUserWithFacebook(){
console.log('Facebook');
//this.nav.setRoot(pantryList);
}
registerUserWithGoogle() {
console.log('Google');
//this.nav.setRoot(pantryList);
}
openSignUpPage(){
console.log('Signup');
//this.nav.setRoot(Signup);
}
openLoginPage(){
console.log('Login');
this.nav.push(Login);
}
openTermsOfService(){
console.log('Terms of service');
}
}
And i want to redirect to my menu (sidemenu) page:
import {Component} from "@angular/core";
import { NavController } from 'ionic-angular';
import { pantryList } from '../pantryList/pantryList';
@Component({
templateUrl: "login.html"
})
export class Login {
email: string;
password: string;
constructor(public navCtrl: NavController) {
}
onLogin() {
this.navCtrl.setRoot(pantryList);
}
}
Forced that thing to work in next way
constructor(
protected app: App
) {
...
get navCtrl(): NavController {
return this.app.getActiveNav();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With