离子2 +角2 - 标签+侧面菜单

时间:2016-02-13 03:59:59

标签: angularjs typescript ionic-framework ionic-view ionic2

我试图加入标签和边栏菜单,我对我做错了什么感到困惑。因为root属于sidemenu ..

import {App, IonicApp, Platform} from 'ionic-framework/ionic';

import {HelloIonicPage} from './pages/hello-ionic/hello-ionic';
import {ListPage} from './pages/list/list';
import {TabsPage} from './pages/tabs/tabs';


// https://angular.io/docs/ts/latest/api/core/Type-interface.html
import {Type} from 'angular2/core';


@App({
  templateUrl: 'build/app.html',
  config: {} // http://ionicframework.com/docs/v2/api/config/Config/
})
class MyApp {
  // make HelloIonicPage the root (or first) page
  rootPage: Type = HelloIonicPage;
  pages: Array<{title: string, component: Type}>;

  constructor(private app: IonicApp, private platform: Platform) {

    this.initializeApp();

    // set our app's pages
    this.pages = [
      { title: 'Hello Ionic', component: HelloIonicPage },
      { title: 'My First List', component: ListPage },
      { title: 'testing tabs', component: TabsPage}
    ];
  }

  initializeApp() {
    this.platform.ready().then(() => {
      // The platform is now ready. Note: if this callback fails to fire, follow
      // the Troubleshooting guide for a number of possible solutions:
      //
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      //
      // First, let's hide the keyboard accessory bar (only works natively) since
      // that's a better default:
      //
      // Keyboard.setAccessoryBarVisible(false);
      //
      // For example, we might change the StatusBar color. This one below is
      // good for dark backgrounds and light text:
      // StatusBar.setStyle(StatusBar.LIGHT_CONTENT)
    });
  }

  openPage(page) {
    // close the menu when clicking a link from the menu
    this.app.getComponent('leftMenu').close();
    // navigate to the new page if it is not the current page
    let nav = this.app.getComponent('nav');
    nav.setRoot(page.component);
  }
}

我是离子新手,我已按照以下教程http://ionicframework.com/docs/v2/getting-started/tutorial/

进行操作

它有标签或侧面菜单,但没有两者。我已导入标签,但我不确定下一步该做什么,因为rootPage属于HelloIonicPage,我不想更改。

1 个答案:

答案 0 :(得分:-1)

目前还不完全清楚为什么你需要这样做,但它是可能的,并且附加的链接有代码,我合并了模板生成的两个程序。生成的程序使用tab1页作为&#39;入门&#39;页。每个标签页都提供侧栏菜单。

  1. 我将这些文件夹复制到&#39;标签的页面文件夹中。程序到&#39; sidemenu&#39;程序

  2. 来自&#39;入门&#39;我复制了导航条码和侧栏的菜单。这似乎是由标签2和标签3页面继承,包括指定的标题(不确定原因)。所以我在每个页面中添加了一个带有tab2和tab3标题的h1作为标记。

  3. 我修改了app.ts文件以导入步骤1中添加的页面。

  4. 我添加了import语句来导入app.core.scss中的page1,page2和page3 html文件

  5. 该方法可能允许在侧栏上添加登录屏幕和其他实用程序屏幕(如搜索)。

    Merged Sidemenu and Tabs code in ionic 2

相关问题