Ionic Change back button icon for one page only

我怕爱的太早我们不能终老 提交于 2019-12-10 12:16:14

问题


Using app.module.ts, setting IonicModule.forRoot(MyApp,{backButtonIcon:"close"}) will set all the back icons in my app to close icon. However, I want to apply this in only a page or two of the app, and keep the rest with the default, or maybe third icon I choose. Does anyone know how can that be done without implementing my own button and functions for the back functionality?


回答1:


By having an ion-toolbar in the ion-header, it appears on top of the default ion-navbar. So it is a workaround to have a custom header bar with my close icon and my custom function gotoHome(). That's the best way i found to customize the 'navbar' for a particular page.

<ion-header>

    <ion-toolbar>
        <ion-buttons left>
            <button ion-button icon-only (click)="gotoHome()">
                <ion-icon name="close"></ion-icon>
            </button>
        </ion-buttons>
        <ion-title>Title</ion-title>
    </ion-toolbar>

</ion-header>

<ion-content padding>
    ...
</ion-content>


来源:https://stackoverflow.com/questions/44217442/ionic-change-back-button-icon-for-one-page-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!