无法移动到离子侧菜单

时间:2017-09-20 10:14:29

标签: javascript html css ionic-framework hybrid-mobile-app

决定移动混合应用程序,现在我陷入了某种愚蠢的境地...... 在IONIC中打开了一个新的侧面菜单项目,并希望在侧面菜单中添加页面。 问题是,当我将新页面添加到app.html时,它只是没有移动到新页面,整个应用程序只是停留在我点击之前的同一页面上新的一页。 (侧面菜单仍然打开和关闭,但没有其他..) 必须说模板附带的前两页工作正常,直到我选择新页面。

希望你能帮助我:)。

这是app.html:

  <ion-menu [content]="content">
<ion-header>
<ion-toolbar>
  <ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<ion-list>
  <button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
    {{p.title}}
  </button>
</ion-list>
</ion-content>

</ion-menu>

<!-- Disable swipe-to-go-back because it's poor UX to combine STGB with side menus -->
<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>

和我的App.ts

import { Component, ViewChild } from '@angular/core';
import { Nav, Platform } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';

import { Page1 } from '../pages/page1/page1';
import { Page2 } from '../pages/page2/page2';
import { ExternalLinksPage } from '../pages/ExternalLinks/ExternalLinks';



@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  @ViewChild(Nav) nav: Nav;

rootPage: any = Page1;

pages: Array<{title: string, component: any}>;

constructor(public platform: Platform) {
 this.initializeApp();

// used for an example of ngFor and navigation
this.pages = [
  { title: 'מסך הבית', component: Page1 },
  { title: 'מתכונים', component: Page2 },
  { title: 'קישורים חיצוניים', component: ExternalLinksPage }
];

}

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

openPage(page) {
// Reset the content nav to have just this page
// we wouldn't want the back button to show in this scenario
this.nav.setRoot(page.component);
}
}

由于

0 个答案:

没有答案