2016-03-07 27 views
0

我正嘗試在navigator中用ionic2創建一個簡單的菜單。我已經跟蹤了tut,但它不會在我的應用程序中工作,我似乎無法理解爲什麼。這是當前代碼我有: app.ts菜單不會出現在與打字稿的ionic2

import {App, Platform} from 'ionic-angular'; 
import {TabsPage} from './pages/tabs/tabs'; 
import {MenuPage} from './pages/menu/menu'; 

@App({ 
    templateUrl: 'build/index.html', 
    config: {} // http://ionicframework.com/docs/v2/api/config/Config/ 
}) 
export class MyApp { 
    static get parameters() { 
    return [[Platform]]; 
    } 

    constructor(platform) { 
    this.rootPage = TabsPage; 
    platform.ready().then(() => { 
    }); 
    } 

} 

的index.html:

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

menu.ts:

import{Page, MenuController} from 'ionic-angular'; 
@Page({ 
    templateUrl: 'build/pages/menu/menu.html' 
}) 
export class MenuPage { 
constructor(menu: MenuController) { 
    this.menu = menu; 
} 

openMenu() { 
    this.menu.open(); 
} 

} 

menu.html:

<ion-menu persistent="true" [content]="content"> 
    <ion-toolbar> 
    <ion-title>Instellingen</ion-title> 
    </ion-toolbar> 
    <ion-content> 
    <ion-list> 
     <button ion-item> 
     Informatie 
     </button> 
     <button ion-item> 
     Veelgestelde vragen 
     </button> 
     <button ion-item> 
     Algemene Voorwaarden 
     </button> 
    </ion-list> 
    </ion-content> 
</ion-menu> 

據文件去這應該w ork ..但它不會在我的情況下,所以有人看到我失蹤?

沒有錯誤,我沒有看到任何問題正常查看加載。

import{Page, MenuController} from 'ionic-angular'; 
@Page({ 
    templateUrl: 'build/pages/menu/menu.html', 
    selector:'app-menu' 
}) 
export class MenuPage { 
constructor(menu: MenuController) { 
    this.menu = menu; 
} 

openMenu() { 
    this.menu.open(); 
} 

} 

而且在您的index.html文件中加入:只是沒有菜單,我跟着入門toturial

+0

您看到什麼問題? – Pogrindis

+0

您是否在瀏覽器控制檯中收到錯誤消息?你遵循什麼標準? –

+0

沒有錯誤,我沒有看到任何問題查看加載只是沒有菜單,並遵循入門toturial http://ionicframework.com/docs/v2/getting-started/tutorial/project-structure/ –

回答

0

也許你在前人的精力Menu類的@Page metatada添加選擇屬性

<app-menu></app-menu> 
<ion-nav #content [root]="rootPage"></ion-nav> 

編輯: 添加以下到@Component元數據(例如,在第1頁類)

<ion-navbar *navbar hideBackButton> 
    <button menuToggle> 
     <ion-icon name='menu'></ion-icon> 
    </button> 
    <ion-title>Tab 1</ion-title> 
</ion-navbar> 

我已更新您的codepen:http://codepen.io/anon/pen/LNGzJN

+0

這也沒有工作,保持空載。 –

+0

和如果添加元數據的指令在MyApp的類: '@App({ templateUrl: '構建/ index.html中', 指令:[MenuPage], 配置:{}} )' –

+0

例外:意外指令值'未定義'組件'MyApp'的視圖我輸入錯了嗎?這裏是我的問題codepen http://codepen.io/sjerd/pen/xVZdjb –