AngularJS possible unhandled rejection when using

2019-02-09 08:32发布

After I have changed from ngRoute to angular-ui-router the console shows always 4 errors stating: Possibly unhandled rejection: {}

I did not noticed any "problem" in the behavior of the application I am building, but I would like to get rid of it.

Any idea what does it mean and how to solve it?

Here an screenshot: enter image description here

3条回答
走好不送
2楼-- · 2019-02-09 09:13

This issue is found in 1.5.9 and 1.6.0-rc-0. More details at https://github.com/angular-ui/ui-router/issues/2889

Patch solution is to manually disable unhandled rejections.

app.config(['$qProvider', function ($qProvider) {
    $qProvider.errorOnUnhandledRejections(false);
}]);
查看更多
▲ chillily
3楼-- · 2019-02-09 09:15

I used the next solution

    $http.get('/api/get').then(function(result) {
       // ... stuff here
    }).catch(angular.noop);

it's equals to

$http.get('/api/get').then(function(result) {
  // ... stuff here
}).catch(function(){});
查看更多
地球回转人心会变
4楼-- · 2019-02-09 09:33

Resolve the promise with false if you are trying to abort a transition.

查看更多
登录 后发表回答