How to UPDATE - binding data from different page in Ionic? (SOLVED)

Hi Ionicers!

First of all, you can check at my codepen here : http://codepen.io/harked/pen/eNMzoj

There are 2 main page right there : Basket and Order page.
I bind the data between Basket page to Order page with ng-controller and it’s successfully works.
But when i change the Item in basket page, i.e delete some item and then click “Confirm”, the price in Order page didnt change.
How to push data from basket to order page (in order to my case)?

Any help would be greatly appreciated.

Hello harkedian

I think you should put your foodlists data in service, and inject that service in both controller.

you have bind different controller with both basket and order tab in route.

But you are loading controller by adding ng-controller in order tab

  <div class="item item-divider">Restaurant 1<span ng-controller="BasketTabCtrl" class="item-note">${{getTotalPrice()}}</div>

ng-controller=“BasketTabCtrl” will load basketTabCtrl again and foodlist will be initialize again so you are not getting changes in order page.

so put data and common method that you are using on both tab in to angular service and inject service into both controller

Here is your working code

http://codepen.io/anon/pen/VLXXPg

1 Like

The price in Order page doesn’t change even tho the variable changes because it has already been “painted”, angular doesn’t know the variable has changed.
You could, as @jariwalabhavesh suggested, put it on a service, or simply don’t cache the order view with cache-view = false to force it to get the updated variable.

1 Like

Hi @jariwalabhavesh.
Great thanks for your kind help.
Perfectly works in my real app :wink:


Thanks for the explanation, @ibaiapellaniz. :smile: