Search code examples
angularjscordovaonsen-ui

Phonegap/Onsen/AngularJS Remove Page after Pagechange


I´m developing an App with Cordova Onsen-UI and AngularJS.

I have several pages in my application.

I change the page with that command:

$scope.ons.navigator.pushPage('msg_det.html', { animation: 'slide' });

I´ve noticed the following: If I call the same page with the same command again, the old page still exist.

(I have a html element

for example: <img id="test" src="sadf.png" />

with an ID. At the first time, the access by id works.

$("#test").css("left", "20px");

After the second time it is not been working anymore.) That is a sign, that the id still exists a second time.

Is there a chance to build the page "msg_det" new and delete the old one.


Solution

  • It seems that you need to check it manually

    $scope.ons.navigator.getPages() gives you all the pages that currently exist, so check if your page already exist call the destroy() on old page.

    for more info take a look at http://onsen.io/guide/overview.html#PageNavigation