refresh previous page in onsen ui on back button

半城伤御伤魂 提交于 2020-01-04 05:58:00

问题


Hello i am working on onsen ui and have made a simple demo,it contains two pages page1 and page 2,my problem is i want to reload my page1 when i press ons-back-button from page2,as onsen ui maintains a pagestack,i cant do this,i searched a lot for this,but no luck,can anyone please help me how to do this?

my code is as below:

page1.html

    <ons-page ng-controller="listingController">

.
.
.

    </ons-page>

page2.html

<ons-page ng-controller="listingController">
    <ons-toolbar style="background: #da1e3e;" fixed-style>
        <div class="left">
            <ons-back-button >Back</ons-back-button>
        </div>
</ons-toolbar>
<ons-page>

回答1:


In OnsenUI 2.0 there is a refresh parameter for popPage() to achieve this behavior, and there is already an issue to make a refresh-and-popPage from ons-back-button.

In OnsenUI 1.x you can refresh the previous page using one of these answers: AngularJS OnsenUI reload parent page on nav.popPage() in child page

Then, you can use ons-back-button style and call your popAndRefresh function:

<style>
  .ons-back-button__icon {
    vertical-align: top;
    font-size: 36px;
    margin-left: 8px;
    margin-right: 2px;
    width: 16px;
    display: inline-block;
    padding-top: 1px;
  }
</style>

<ons-toolbar-button class="toolbar-button--quiet" onclick="popAndRefresh()">
  <ons-icon class="ion-ios-arrow-back ons-back-button__icon"></ons-icon>
  Back
</ons-toolbar-button>


来源:https://stackoverflow.com/questions/33750805/refresh-previous-page-in-onsen-ui-on-back-button

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