Ionic2:未捕获(承诺):无效链接:日历

时间:2018-07-11 11:19:18

标签: ionic2 side-menu

我已经在Ionic2中实现了一个侧面菜单。当我单击侧面菜单上的“事件”或“地图”按钮时,出现“无效链接”,有时会出现“插入无效视图”错误。我尝试从日历和gmap中删除引号,但无法解决。 请指导。

这是我的TS文件:

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();
 }
}

这是我的HTML代码:

<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>

0 个答案:

没有答案