Replace ui router 0.2 with 1.0.0

I upgraded ui-router v0.2 to 1.0.0, but I have some problems with my existing code. Therefore, I read in official documents that

$rootScope.$on('$stateChangeStart'

now replaced by $transitions.onStart({},

same $rootScope.$on('$stateChangeSuccess'with$transitions.onSuccess({},

So far so good. But in my source code, I have the following:

$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
   // some code here
   $state.go(toState.name, toParams);
}

I tried the following:

$transitions.onStart({}, function (toState, toParams) { 
     $state.go(toState, toParams);
}

But toStatealso toParamsinaccessible ... I looked at the documents, but I can’t understand what should I do here. Any help would be appreciated. Thank.

0
source share
1 answer

The documentation is here: http://angular-ui.imtqy.com/ui-router/feature-1.0/ You can configure custom callbacks for specific scenarios, such as:

$transitionsProvider.onBefore({ to: 'my.state', from: '*' }, function(AsyncService) {
  return AsyncService.doSomeAsyncThing();
});
0

Source: https://habr.com/ru/post/1653283/


All Articles