Description
The Bug
When a $state.go
is called with {notify: false}
as follows, a bug occurred:
$state.go('foo', {}, {notify: false})
On the next state change, the current controller will be initialised a second time.
Plunker Link
Follow the steps to reproduce on Plunker:
http://plnkr.co/edit/wMiVOb?p=preview
and
http://plnkr.co/edit/iqDuQrsjVWfySOrg1nv0?p=preview
Navigate to foo
state, then click on Change URL button. The URL changes without reloading the controller, which is the wanted behavior.
Click on the Change state 1 button.
The URL changes, I see a $stateChangeStart
event with the current URL parameters, the controller is called.
Then I see a $stateChangeSuccess
event with the new URL parameters and the controller is called again.
If you click now on the Change state 2 button, both events have the same URL parameters, so there is no double controller call.
It looks like the notify: false
parameter don't do a "real" URL parameters update, so UI-router has to do a double state change to reconcile the parameters it knows with the ones it discovers, then with the ones requested...
I saw a number of issues more or less related, like #1758, but I am not sure if they are entirely the same. So I went ahead and made my own issue with a demonstration to illustrate it. 😄