How to update $scope using $ionicView.enter


I need to display profile details of a user using a view call defined as:

  .state('app.user', {
    url: "/user/:userId",
    views: {
      'menuContent': {
        templateUrl: "templates/user.html",
        controller: 'UserCtrl'

Since Ionic cache the $scope I need to reload data of the user every time I enter in app.user state so that I’m using $scope.$on(’$ionicView.enter’, function (event, state) { … } to detect the event.

I discovered I have all the info of current $scope in event.targetScope and my userId param in state.stateParams.userId, but if I try to change them nothing happen in the view and if I try to call an $apply I get the $digest error.

I saw that there was a bug on this so that now I have the 1.0.0-rc.4 version, but I still I can’t solve my problem.



This should get rid of the $digest error:

        //$timeout executes $scope.$apply() automatically but safely w.r.t digest cycle
        function () {
            $scope.whatever = "something";

Great post at which explains a lot about the digest cycle.