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:
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(){});
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);
}]);
If you look at the logic for uiCanExit in angular-ui-router file(I'm using v1.0.16), it checks only for resolved promise but not for a rejected promise. It is something like:
promise.then(function (val) {
return val !== false ? next_transition : current_transition
});
Just return a resolved promise with false value to cancel transition. e.g.,
defer.resolve(false)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With