ons-navigator data not showing properly for muliple pages



  • I have used ons-navigator and created 3 pages this is my codepen and passing data to 2nd and third page but when I press back button from 3rd page it shows data of 3rd page not second page and again I press back from 2nd page it shows correct data and then goes to 1’st page


  • Onsen UI

    @Gaurav navigator.topPage is a pointer to the last page, so when you push or pop pages this pointer changes. Therefore, your page-2’s title changes when you push page-3 and somehow Angular doesn’t refresh the view when you pop back to page-2.

    In any case, you want to avoid so many updates, and an easy way to do it is to stop depending on topPage pointer:

    <ons-page ng-init="data = componentnNavigator.topPage.data">, and then access this new object: {{ data.title }}. It can also be done in a page’s controller but I guess ng-init is quite handy.



  • Thanks Fran this worked for me :grinning:


Log in to reply