0
votes

$ionicview.loaded doesn't work.

I probably miss something ?

Can you help me, please ?

.

Ionic Version: 1.0.0-beta.13

I checked this reference before to post :

app.js

app.config(function($stateProvider, $urlRouterProvider) {
  $stateProvider

    .state('app', {
      url: "/app",
      cache : false,
      templateUrl: "templates/menu.html",
      controller: 'AppCtrl'
    })

.state('app.myPage', {
      url: "/myPage",
      cache : false,  
      views: {
        'menuContent' :{
          templateUrl: "templates/myPage.html",
          controller: 'myCtrl'
        }
      }
    })

controllers.js

appControllers.controller('myCtrl', ['$scope', '$rootScope', '$ionicScrollDelegate', '$ionicPlatform', '$ionicLoading', function($scope, $rootScope, $ionicScrollDelegate, $ionicPlatform, $ionicLoading) {

  console.log("step4"); // ok

  ionic.Platform.ready(function() {
    console.log("step5"); //ok

    $rootScope.$on('$ionicView.enter', function(){
      console.log("step7"); //no works
    });

    $rootScope.$on('$ionicView.loaded', function(){
      console.log("step6"); //no works
    });



    $rootScope.$on('$ionicView.leave', function(){
      console.log("step8"); //no works
    });

    $rootScope.$on('$ionicView.afterEnter', function(){
      console.log("step9"); //no works
    });

  });

}]);

I tried this too from myPage.html

<ion-view cache-view="false" view-title="My Title!">
  ...
</ion-view>
1

1 Answers

3
votes

update your controller to this:

appControllers.controller('myCtrl', ['$scope', '$rootScope', '$ionicScrollDelegate', '$ionicPlatform', '$ionicLoading', function($scope, $rootScope, $ionicScrollDelegate, $ionicPlatform, $ionicLoading) {


    $scope.$on('$ionicView.enter', function(){
      console.log("step7"); 
    });

    $scope.$on('$ionicView.loaded', function(){
      console.log("step6");
    });



    $scope.$on('$ionicView.leave', function(){
      console.log("step8"); 
    });

    $scope.$on('$ionicView.afterEnter', function(){
      console.log("step9"); 
    });


}]);