2017-06-05 49 views
1

我克隆使用後退導航按鈕沒有顯示出來

離子開始myProjectName教程

的代碼,並改變根據離子3的項目,現在,有一個文件list.html,它在打開側面菜單的標題處有一個按鈕。我想在那裏有一個後退按鈕,並刪除了側面菜單打開的代碼。預計後退按鈕會自動顯示,但它沒有發生,而是顯示標題,沒有任何按鈕,只有標題寫入。

在這個項目

,你會發現list.html,我如下已經改變了它:

<ion-header> 
    <ion-navbar> 
    <ion-title>My First List</ion-title> 
    </ion-navbar> 
</ion-header> 
<ion-content> 
    <ion-list> 
    <button ion-item *ngFor="let item of items" (click)="itemTapped($event, item)"> 
     <ion-icon name="{{item.icon}}" item-left></ion-icon> 
     {{item.title}} 
     <div class="item-note" item-right> 
     {{item.note}} 
     </div> 
    </button> 
    </ion-list> 
</ion-content> 

它只是有一個標題,沒有後​​退導航按鈕,可以帶我到根頁

回答

1

可以在app.component.ts

itemTapped(item) { 
    // close the menu when clicking a link from the menu 
    this.menu.close(); 
    // navigate to the new page if it is not the current page 
    this.nav.push(page.component); 
} 
+0

是啊!它的工作,謝謝@sau_Patil – devanshsadhotra

0

這裏的一些代碼爲離子標題。

<ion-view> 
<ion-nav-bar> 
    <ion-nav-buttons side="left"> 
     <button class="button button-clear ion-arrow-left-c " ng-click="backButton()"></button> 
    </ion-nav-buttons> 
    <ion-nav-buttons side="right"> 
     <button class="button button-clear btn-white ion-android-settings header-icon-size " ng-click="openDrawer()"></button> 
    </ion-nav-buttons> 
</ion-nav-bar> 
<ion-content> 
    <!-- here content --> 
</ion-content> 
</ion-view> 

讓我知道它是否適合你?

+0

您所提供的代碼是正確的,但它是不可行的,因爲呼籲後退按鈕的功能手動將帶我回到以前的頁面在添加下面的代碼它的頂部,IONIC 2提供默認後退按鈕,很容易運作 – devanshsadhotra