1

I have implemented a side-menu in Ionic2.I am getting "Invalid link" when i click on the Event or Map button on the side-menu and sometimes i get the error as "Invalid Views to insert". I tried removing quotes from the calendar and gmap but it does not work out. Please guide.

This is my TS file:

import { Component } from '@angular/core';
import { Platform , IonicPage } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { CalendarPage } from '../pages/calendar/calendar'
import { GmapPage } from '../pages/gmap/gmap'
import firebase from 'firebase';
import { LoginPage } from '../pages/login/login';
import { ViewChild } from '@angular/core';
import { NavController } from 'ionic-angular/navigation/nav-controller';
import { AuthProvider } from '../providers/auth/auth';
@IonicPage() 
@Component({
templateUrl: 'app.html'
})
export class MyApp {
calendar: CalendarPage;
gmap: GmapPage;
@ViewChild('nav') nav: NavController;
rootPage: any = CalendarPage;
pages = []

constructor(platform: Platform, statusBar: StatusBar, splashScreen:SplashScreen,
public authProvider: AuthProvider) {
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();
  splashScreen.hide();
  const unsubscribe = firebase.auth().onAuthStateChanged(user => {
    if (!user) {
      this.rootPage = 'LoginPage';
      unsubscribe();
    } else {
      this.rootPage = 'EventPage';
      unsubscribe();
    }
  });
});
}
    onLoad(page : string) {
  this.nav.setRoot(page);
  }
  onLogout(){
    this.authProvider.logoutUser();
 }
}

This is my HTML code :

<ion-menu [content] = "nav">
 <ion-header>
<ion-toolbar>
    <ion-title>Menu</ion-title>
      </ion-toolbar>
     </ion-header>
     <ion-content>
      <ion-list>
       <button ion-item  (click) = "onLoad('calendar')">Events</button>
       <button ion-item  (click) = "onLoad('gmap')">Maps</button> 
       <button ion-item  (click) = "onLogout()">Logout</button>

              </ion-list>
            </ion-content>
          </ion-menu>


  <ion-nav [root]="rootPage" #nav></ion-nav>
  • When i remove the single quotes from "onLoad('calendar')" to "onLoad(calendar) , i get the error : Uncaught (in promise) : Invalid views to insert. – SHACHINDRA TRIPATHI Jul 13 '18 at 10:38

0 Answers0