angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.56k stars 3.01k forks source link

Unknown provider: $transitionsProvider <- $transitions #3720

Closed jcugmas closed 4 years ago

jcugmas commented 5 years ago

UI Router version : 1.0.18 Angular version: 1.6.4 Webpack version: 4.15.1 Webpack dev server version: 3.1.4

Hello everyone,

I'm developing an AngularJS app and I'm using UI router to design my routes. Recently, I updated my webpack (3 -> 4) and my @uirouter (1.0.7->1.0.18) version, and from nowhere, I have the following error thrown:

Error: [$injector:unpr] Unknown provider: $transitionsProvider <- $transitions

Results : my hooks don't work et my login page is not displayed.

There is some important lines of my app.js which is my main module :

import uiRouter from '@uirouter/angularjs';
...
export default angular.module(app,[uiRouter,....])
     .value('constants',constants)
    .config(config)
    .run(run)
    .run(authHook)
    .name;

And there is a draft of one of my hook where $transitions service is used :

authRequiredHook.$inject = ['$transitions','$location'];
export default function authRequiredHook($transitions,$location) {

    $transitions.onStart({ to:(state) => {
            return state.includes.index;
        }},(trans) => {
        let authService = trans.injector().get('AuthenticationService');
        let localStorageService = trans.injector().get('LocalStorageService');
        if(!authService.isLoggedIn()){
            localStorageService.logout();
            localStorageService.setReferer($location.path());
            return trans.router.stateService.target('login');
        }
    });
}

Am I doing something wrong ? I've been pulling out hairs of my head for 2 days...

Thank you !

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues may be reopened.

Thank you for your contributions.