Search code examples
javascriptandroidangularjscordovaback-button

Cordova Angular Android back button does not trigger ng-if


In Cordova Angular, back button does not seem to trigger ng-if. I have my code like this:

html

<div class="buttons" ng-if="!isNavButtonActive()">
    <a class="button icon-left ion-chevron-left button-clear">
        {{ isExitBackActive() ? "Exit" : "Back" }}
    </a>    
</div>

controller

$scope.isNavButtonActive = function(){
     return $location.path() === '/app/menu';
}

$scope.isExitBackActive = function(){
     if($rootScope.previousState === '/app/menu') {
        return true;
     } else {
        return false;

The idea is:

from menu landing page if I click new issue page : it will show new issue page with a button as "EXIT".

from menu landing page if I click list of issue : then from list of issue (it should show button "EXIT") I click one of the issue, it will actually go to "new issue page except it is prepopulated" and it should show the page with a button as "BACK". So far it is working ok, but once I click back button, somehow the list issue page still keeping "BACK" as button instead of "EXIT".

Any idea?

The page flow is like this:

Menu -> [EXIT button]New Issue (blank screen)
     -> [EXIT button]List Draft -> [BACK instead of EXIT button]basicly go to new issue page(but prepopulated data) 

Solution

  • For starting point, it looks like isExitBackActive() is returning false. Just console.log before return statements in isExitBackActive() function definition.