JIGAR
JIGAR

Reputation: 302

refresh previous page in onsen ui on back button

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>

Upvotes: 2

Views: 2676

Answers (1)

Fran Dios
Fran Dios

Reputation: 3482

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>

Upvotes: 1

Related Questions