$ionicView in $scope.$on not launching


#1

Hi! My $ionicView events arent launching :frowning:
I’m using the ‘controller as’ syntax

On my Controller. I add this:

angular
  .module('app')
  .controller('GameCtrl', Game);

Game.$inject = ['LangService', 'GameMdl', '$ionicLoading', '$ionicPopup', '$scope'];

function Game(LangService, GameMdl, $ionicLoading, $ionicPopup, $scope) {

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

But It doesn’t launch. I have tried with ‘$ionicView.beforeLeave’ and that doesn’t work too

Thanks for your time :blush:


#2

I am having the same issue with all my events, the only way I can get it to fire is by listening on $rootScope, but this has its own drawbacks as it constantly creates new listener without deregistering, leading to code being executed repeatedly.


#3

For me $ionicView.beforeEnter and afterEnter are not working also. The problem is, ui routers $viewContentLoaded is also not working :frowning:
I am not sure how should i figure when my view is loaded.


#4

i have figured only $ionicView.enter and beforeLeave are firing, others i can’t get.


#5

I am also one of those who are unable to make this functional (pc and android):

$scope.$on('$ionicView.loaded', function(){})

but finally I found at least this one works (placed inside controller) maybe it will help someone:

  ionic.Platform.ready(function() {
     //whatever you need
  });