This has been driving me crazy for the last couple of hours and I can't find a solution still...
Basically I'm changing the state to 404 when a resolve returns an http 404 status code. I'm changing the state in $stateChangeError event. It all works fine, except after the state is changed to 404 it starts another state change back to the original one thus resolving twice. The state itself remains on 404, so after all, it works, but it still makes additional $http requests that are not needed. However, it only works like this if I use $state.go('404', null, { location: false }) OR if the 404 state doesn't have an URL defined at all.
If I have an url defined for the 404 state (/404), then everything works just fine.
Here are 2 pens, demonstrating the issue:
The failing one: http://codepen.io/cprfnaporf/pen/RaqmQN (debug mode, check console: http://s.codepen.io/cprfnaporf/debug/RaqmQN/)
The working one: http://codepen.io/cprfnaporf/pen/MyzdVQ (debug mode, check console: http://s.codepen.io/cprfnaporf/debug/MyzdVQ/)
Any idea how to fix this issue? I'm out of ideas really.
Thanks!
resolveis fired twice ?baseand the one for statebase.profile. You can see in the log (s.codepen.io/cprfnaporf/debug/RaqmQN).404state is loaded...