$state.go doesn’t redirect to given path

i've got a view that's outside of my tabs, now when i try to redirect from that view to a tab i get redirected to the wrong tab. i've made a codepen to show you what i mean since i don't really know how to explain it well see the logs i create in the console

  .controller('MyCtrl', function($scope, $state, $rootScope, $ionicPlatform) {
     $rootScope.$on('$stateChangeStart',function(event, toState, toParams, fromState, fromParams){ 
            // do something
            $scope.from = fromState;
            console.log(fromState);
        })

        $scope.goBack = function(){
            console.log($scope.from.name);
            $state.go($scope.from.name);
        }

    })

Codepen

You should apply the other answers but you have another problem.

The other problem is that, when you click on back button the state is changing to tab.volgend (which is right) but after this is going to tab.alert state... so I'm trying to figure out why is this second redirect happening.

Extract from console.log when clicking back button: enter image description here

My first candidate is:

$urlRouterProvider.otherwise('/tab/alerts');

You shouldn't use ui-route with standard routing, so you should comment this line an add the next in your controller:

  console.log('going to default state');
  $state.go('tab.alerts');

EDIT

The second transition is made by the ionic framework, I have put a breakpoint and check the callstack, check this captures:

1- first call when back is clicked: enter image description here

2- The ionic framework detects a change in the url and.. fires the second transition: enter image description here

I'm going to read more this framework to see if I understand why is this happening... I keep you updated.

You should pass the name of the state to $state.go(), not the state object.

So $state.go($scope.from.name) should solve this for you.

why not simply use

$state.go('stateName', {//for stateParams}, { reload: true });

This happened with me too. Try transitionTo method, instead of go

$state.transitionTo($scope.from.name);

This worked out in my case.

More details can be found here

Edit : I forked your original codepen and it worked there too.. Forked Codepen here