# $ionicView doens't work

**URL:** <https://forum.ionicframework.com/t/ionicview-doenst-work/53537>\
**Category:** ionic-v1\
**Created:** [May 31, 2016, 5:39pm UTC](https://forum.ionicframework.com/t/ionicview-doenst-work/53537 "2016-05-31T17:39:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexcandy91](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@alexcandy91](https://forum.ionicframework.com/u/alexcandy91)\
**Post date:** [May 31, 2016, 5:39pm UTC](https://forum.ionicframework.com/t/ionicview-doenst-work/53537/1 "2016-05-31T17:39:34Z")

</div>

Hello,  
I’m developing an application with Ionc framework ( of course ), and I have a problem. I would like to initialize some variables and execute some function every time I open a view. I’m using $stateProvider methods in the app configuration in order to initialize all routes and I try to use ionic events like this to intercept the opening of the view…  
`$scope.$on("$ionicView.enter", function(event, data){ // handle event alert("State Params: ", data.stateParams); });`

But it works only on a login controller. I try to read a lot of post but no one can give to me a solution. To be sure I also put the app configuration view and the first part of the controller, I hope that someone can help me.

`  
angular.module(‘indexController’, [])  
.controller(‘faceIndexCtrl’,  
function ($scope, $ionicModal, $translate, localstorage, happyBack, $timeout, $state,$ionicPopup, $http, $ionicPlatform, $state, $animate, soundEffects, $rootScope) {

```
    $scope.$on("$ionicView.beforeEnter", function(event, data){
        // handle event
        alert("State Params: ", data.stateParams);
    });

    $scope.$on("$ionicView.enter", function(event, data){
        // handle event
        alert("State Params: ", data.stateParams);
    });

    $scope.$on("$ionicView.afterEnter", function(event, data){
        // handle event
        alert("State Params: ", data.stateParams);
    });

```

…so on…  
`

Thank you so much!
