I'm getting the error NullInjectorError: No provider for NavController. I searched for it and I know I shouldn't inject it into the appcomponent. I'm not doing so, but I still get the error. I have appComponent which is my rootcomponent. As startpage i'm setting my StartPage. In this StartPage i'm injecting the What am I doing wrong?
AppComponent template:
<ion-nav #content [root]="rootPage"></ion-nav>
AppComponent:
export class AppComponent {
rootPage: any = StartPage; //Setting my start page
constructor(
private platform: Platform,
private statusBar: StatusBar,
private splashScreen: SplashScreen) {
}
ionViewDidLoad() {
this.platform.ready().then(() => {
this.statusBar.styleBlackTranslucent();
this.splashScreen.hide();
});
}
}
StartPage:
export class StartPage {
constructor(private navController: NavController){
}
signin(){
this.navController.push(LoginPage);
}
signup(){
this.navController.push(SignupPage);
}
}
Try to import NavCtrl at the top of the file, where you need it (at the top of the StartPage?):
import { NavController } from 'ionic-angular';
And adding it into constructor, as you did, should be enough.
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