IonicView.enter does not start on the child view and its controller

I have two nested states consisting of a parent abstract state and a child state:

.state('app.heatingControllerDetails', { url: "/clients/:clientId/heatingControllers/:heatingControllerId", abstract: true, views: { 'menuContent': { templateUrl: "templates/heatingController.html", controller: 'HCDetailsCtrl' } } }) .state('app.heatingControllerDetails.wdc', { url: "/wdc", views: { 'hc-details': { templateUrl: "templates/heatingControllers/wdc.html", controller: 'WdcDetailsCtrl' } }, resolve:{ hcFamily: [function(){ return 'wdc'; }] } }) 

and two controllers:

  .controller('HCDetailsCtrl',function($scope){ $scope.$on("$ionicView.enter", function (scopes, states) { ... }); }) .controller('WdcDetailsCtrl',function($scope){ $scope.$on("$ionicView.enter", function (scopes, states) { ... }); }) 

When I call state app.heatingControllerDetails.wdc, both controllers are created, but $ ionicView.enter is called only on the parent controller. Any idea?

In the heatingController.html file, the hc-details view is defined as follows:

 <ion-content class="has-header" ng-show="hc"> <div ui-view name="hc-details"></div> <div class="disableContentDiv" ng-hide="hc.state=='Online'"></div> </ion-content> 
+7
state ionic ionic-view
source share
2 answers

When working with nested views, you should use $ionicNavView events instead of $ionicView

However, in the latest release, these events are tapped, and they currently work in a fix: Github problem

0
source share

I found a job for this. Put this in the parent of the view, or put it in the first controller that loads when the application starts. You can use this to observe any changes to the in and out view. Just do a string comparison at the toState emulated ionicView.enter URL well enough to get what I need it for. Keep in mind that you need to use a UI router for this. Hope this helps!

 $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams, options){ if(toState.url == "/video/:Id"){ console.log("Leaving the view."); } }); 
0
source share

All Articles