Angular / Ionic - controller only runs once

前端 未结 5 1706
無奈伤痛
無奈伤痛 2021-02-20 18:57

I\'m starting out with Angular through the Ionic Framework but I am failing to understand why the controller only runs once i.e. I change state, the controller runs, change to a

5条回答
  •  故里飘歌
    2021-02-20 19:13

    You can put the code you want to run in $ionicView.enter:

    controller : function( $scope, $cordovaSQLite ){
        $scope.$on('$ionicView.enter', function() {
            // code to run each time view is entered
        });
    
        ...
    });
    

    See "View LifeCycle and Events": https://ionicframework.com/docs/v1/api/directive/ionView/

提交回复
热议问题