Menu after sign in Page Nav and NavController ionic 2 +


#1

Hi,

I am trying to re create menu after connexion page. But since my last update beta 35 -> 2.0.0 rc3 the way to use Nav and NavController has changed. I have to use ViewChild but I don’t really understand how it work …

Now, when I load my menu page (after sign in page) I get this error :

Error: No provider for NavController! at NoProviderError.BaseError

tabs.html

<ion-menu [content]="content" class="tabs">
  <ion-toolbar [ngStyle]="style.background">
    <img [ngStyle]="style.background" src="menu.png"/>
  </ion-toolbar>
  <div [ngStyle]="style.background" class="bouton-container">
    <button ion-button center class="bouton-account" large [ngStyle]="style.fabAlert" round>
      <ion-icon name="person"></ion-icon>
    </button>
  </div>
  <ion-content class="tabs-content" [ngStyle]="style.header">
    <ion-list [ngStyle]="style.header">
      <button class="tabs-button" [ngStyle]="style.header"
      color="mag" menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
      <ion-icon name="{{p.icon}}"></ion-icon>
      {{p.name}}
    </button>
  </ion-list>
</ion-content>
</ion-menu>

<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>

tabs.page.ts

import { MessagesPage } from '../messages/messages/messages.page';

@Component({
  templateUrl: 'tabs.html',
  selector: "std-tabs"
})
export class TabsPage {
   // @ViewChild('content') nav: Nav
  @ViewChild(Nav) nav: Nav;
  public rootPage: any = MessagesPage;
  public pages: Array<{title: string, component: any}>

  constructor(private platform: Platform,
  //public nav:NavController,
  ...
  public style:StyleService) {

 .... some code

  }

  ... some methode
  }

singin.page.ts where I call navController ( maybe am I supposed call Nav and not Nav Controller)

import { Component } from '@angular/core';
import { NavController, ToastController, LoadingController } from 'ionic-angular';
//import { ControlGroup } from '@angular/common';
import { TabsPage } from '../tabs/tabs.page';



@Component({
    templateUrl: 'signin.html'
})
 
export class SigninPage {


constructor(public userService: UserService, 
    private nav: NavController, 
    ... import
    public storage:Storage) {
    ... some code
}
 
public onSubmit(authForm: any) {
    if(authForm.valid) {
        this.userService.connectUser(authForm.value)
            .subscribe((user)=> this.connectSuccess(user, loading);
    } 
}   

private connectSuccess(user: any, loading){
    loading.dismiss();
    this.nav.setRoot(TabsPage);
}

}

On beta 35 everything was working fine, but now I stick on this error since 2 days …
Any ideas ?

(Sorry for my english)