angular-ui / ui-router

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

angular ui router creates error messages with angular 1.6.0 #3120

Closed david-gang closed 7 years ago

david-gang commented 7 years ago

Hi all,

At lines https://github.com/angular-ui/ui-router/blob/legacy/release/angular-ui-router.js#L2904-L2907 we use $q.reject.

Due to a breaking change in angular 1.6.0 (https://github.com/angular/angular.js/blob/master/CHANGELOG.md) (I think this is https://github.com/angular/angular.js/commit/e13eeabd7e34a78becec06cfbe72c23f2dcb85f9) there are error messages sent to the console.

angular.js:14239 Possibly unhandled rejection: {}

Thanks,

christopherthielen commented 7 years ago

Fixed in 0.3.2 by 66ab048

maxim-shaw commented 7 years ago

Chris, same error appear with angular 1.6.1. Does ui-router require fixes? Error: transition superseded at $StateProvider.$get (http://localhost:8000/bower_components/angular-ui-router/release/angular-ui-router.js:2909:37) at Object.invoke (http://localhost:8000/bower_components/angular/angular.js:4842:19) at http://localhost:8000/bower_components/angular/angular.js:4636:37 at Object.getService [as get] (http://localhost:8000/bower_components/angular/angular.js:4783:32) at http://localhost:8000/bower_components/angular-ui-router/release/angular-ui-router.js:3696:17 at Object.invoke (http://localhost:8000/bower_components/angular/angular.js:4842:19) at http://localhost:8000/bower_components/angular/angular.js:4645:62 at forEach (http://localhost:8000/bower_components/angular/angular.js:357:20) at createInjector (http://localhost:8000/bower_components/angular/angular.js:4645:3) at doBootstrap (http://localhost:8000/bower_components/angular/angular.js:1838:20) Possibly unhandled rejection: {}

christopherthielen commented 7 years ago

As my previous comment says, this should be fixed in 0.3.2 0.4.2 (and 1.0)

Steve-Mc commented 7 years ago

Still seeing this in 0.3.2

ndpdarshana commented 7 years ago

I'm also seen this in 0.3.2.

It's seems to be appear when $state is use as conditional manner if(authService.validate()){ $state.go('home.dashboard'); }else{ $state.go('login'); }

christopherthielen commented 7 years ago

Update to 0.4.1 or 1.0

dashawk commented 7 years ago

Still having some issues.

with Angular 1.6.2 Angular-ui-router 0.4.2

bkinsey808 commented 7 years ago

upgrading to 0.4.2 fixed this issue for me (with angular 1.6.2)

dashawk commented 7 years ago

I got "transition prevented" error. with these versions.

greatsayan commented 7 years ago

I got an error too. Angular 1.6.2 with ui-router 0.4.2

The problem seems coming from the ui-sref

TypeError: g.get is not a function at R.controller.$$addStateInfo

johnnynode commented 7 years ago

same here!

Error: transition superseded
    at $StateProvider.$get (http://127.0.0.1:9000/bower_components/angular-ui-router/release/angular-ui-router.js:2903:42)
    at Object.invoke (http://127.0.0.1:9000/bower_components/angular/angular.js:4862:19)
    at http://127.0.0.1:9000/bower_components/angular/angular.js:4656:37
    at getService (http://127.0.0.1:9000/bower_components/angular/angular.js:4803:32)
    at injectionArgs (http://127.0.0.1:9000/bower_components/angular/angular.js:4828:58)
    at Object.invoke (http://127.0.0.1:9000/bower_components/angular/angular.js:4854:18)
    at http://127.0.0.1:9000/bower_components/angular/angular.js:7965:43
    at forEach (http://127.0.0.1:9000/bower_components/angular/angular.js:357:20)
    at Object.<anonymous> (http://127.0.0.1:9000/bower_components/angular/angular.js:7963:13)
    at Object.invoke (http://127.0.0.1:9000/bower_components/angular/angular.js:4862:19) Possibly unhandled rejection: {}
dashawk commented 7 years ago

I just solved this problem by updating angular-animate to 1.6.2 as well

andertun commented 7 years ago

I have this issue with Angular 1.6.4 ui-router 0.4.2

But only when using the minified version of ui-router (bower_components/angular-ui-router/release/angular-ui-router.min.js).

When I minify it myself the issue goes away.

msudgh commented 7 years ago

Still having this issue.

angular: 1.6.4 angular-animate: 1.6.4 angular-ui-router: 0.4.2

amshekar commented 7 years ago

I solved it by updating the html from <a href="/#/profile">Profile</a> to <a href="/#!/profile">Profile</a>

i.e /#/ from /#!/

below are my angular ,animate and ui-router versions angular: 1.6.4 angular-animate: 1.6.4 angular-ui-router: 0.4.2

greatsayan commented 7 years ago

Don't have the problem anymore. angular: 1.6.4 angular-animate: 1.6.4 angular-ui-router: 0.4.2

palmeranderan commented 7 years ago

Had some troubles but FINALLY found the mistake, keep attention to the parenthesis: Correct Way: YourService.getData.then( function(res) { $scope.userWithQ = res.data; }, function(error) { //unused } ); My mistake was to close the ")" before the function error and visual Studio 2015 doesn't advice for a mistake. MY Mistake: YourService.getData.then( function(res) { $scope.userWithQ = res.data; }), function(error) { //unused }; Hope u find this helpful

bernardolm commented 6 years ago

OK with: angular: 1.6.6 angular-ui-router: 0.4.2

hugsbrugs commented 6 years ago

I have the problem with angular: 1.6.8 angular-animate: 1.6.8 angular-ui-router: 0.4.2 Fixed it by including non minified version of ui-router (being minified by my gulp process)

soroushNeshat commented 6 years ago

if u are using angularJs 1.6.0+ then u have to use Angular-ui-router 1.0.0+

soroushNeshat commented 6 years ago

plus $stateChange is not working in angular-ui-router anymore , u must use transition hook instead . read more here : https://ui-router.github.io/guide/transitionhooks

dashawk commented 6 years ago

Here is an example that I used in my app:


$transitions.onBefore({ to: 'app.dashboard' }, function (transition) {
    if (!AUTHENTICATED) {
        return $state.target('app.login');
    }
}, { priority: 10 });
soroushNeshat commented 6 years ago

@dashawk better to change this line of your code return $state.target('app.login'); to return transition.router.stateService.target('app.login');

pawanannigeri commented 6 years ago

Hi,

I have migrated my angular js from 1.5.9 to 1.6.9 and angular ui router to 1.0.15, resolve property inside multiple views is not working. Below is the code for the reference...

$stateProvider .state('home', { data: { pageTitle: '' }, url: '/', views: { 'header': { templateUrl: 'xview/common/header.jsp' }, 'header-band': { templateUrl: 'xview/common/home-carousel.jsp', controller: 'CarousalController', controllerAs: 'carousal' }, 'message-container': { templateUrl: 'xview/common/message-container.jsp', controller: 'MessageContainerController', controllerAs: 'messageContainer', resolve: { successMessages: ['RestService', function (RestService) { var params = { action: 'manage_user', method: 'get_validationrules', url: RESOURCE_CONTEXT_PATH+'/assets/resources/successcodes.json' };

                  return RestService.getConfig(params, true);
                }], 
                appConfig: ['RestService', function (RestService) {
                  var params = {action: 'config_manage', method: 'config_home', data: {}};

                  return RestService.getData(params, true);
                }]
              }
            },
            'nav': {
              templateUrl: 'xview/navigation/home-nav.jsp',
              controller: 'LoginController',
              controllerAs: 'loginNav', 
              resolve: {
                validations: ['RestService', function (RestService) {
                  var params = {
                    action: 'manage_user', 
                    method: 'get_validationrules', 
                    url: RESOURCE_CONTEXT_PATH+'/assets/resources/validationrules.json'
                  };

                  return RestService.getConfig(params, true);
                }]
              }
            },
            '': {
              templateUrl: 'xview/common/home.jsp',
              controller: 'AssetsController',
              controllerAs: 'asset'
            },
            'footer': {
              templateUrl: 'xview/common/footer.jsp',
              controller: ['LocaleService', 'AssetsService', '$location', '$state',
                function (LocaleService, AssetsService, $location, $state) {
                  this.changeLanguage = function (locale) {
                    LocaleService.setLocaleByDisplayName(locale);

                    /* 
                     * During language switch event, if the user is in help&support page
                     * we should refresh the same ng-view to switch help&support page based on the lang
                    */
                    if ($location.path() === '/nl-help') {
                      $state.go('home.nl-help', {}, {reload: true});
                    } else if ($location.path() === '/index-logged-in/help') {
                      $state.go('home.index-logged-in.help', {}, {reload: true});
                    }
                  };
                  if (AssetsService.getAppConfig()) {
                    this.portalVersion = AssetsService.getAppConfig().config.PORTAL_VERSION;
                    if (!this.portalVersion) {
                      this.portalVersion = '-';
                    }
                  }
                }],
              controllerAs: 'footer'
            }
          }
        })