{"action":"created","issue":{"url":"https://api.github.com/repos/angular-ui/ui-router/issues/2485","labels_url":"https://api.github.com/repos/angular-ui/ui-router/issues/2485/labels{/name}","comments_url":"https://api.github.com/repos/angular-ui/ui-router/issues/2485/comments","events_url":"https://api.github.com/repos/angular-ui/ui-router/issues/2485/events","html_url":"https://github.com/angular-ui/ui-router/issues/2485","id":128673866,"number":2485,"title":"$stateChangeSuccess is fired before previous state $scope is destroyed in 0.2.16","user":{"login":"bighuggies","id":597021,"avatar_url":"https://avatars.githubusercontent.com/u/597021?v=3","gravatar_id":"","url":"https://api.github.com/users/bighuggies","html_url":"https://github.com/bighuggies","followers_url":"https://api.github.com/users/bighuggies/followers","following_url":"https://api.github.com/users/bighuggies/following{/other_user}","gists_url":"https://api.github.com/users/bighuggies/gists{/gist_id}","starred_url":"https://api.github.com/users/bighuggies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bighuggies/subscriptions","organizations_url":"https://api.github.com/users/bighuggies/orgs","repos_url":"https://api.github.com/users/bighuggies/repos","events_url":"https://api.github.com/users/bighuggies/events{/privacy}","received_events_url":"https://api.github.com/users/bighuggies/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular-ui/ui-router/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":{"login":"christopherthielen","id":2053478,"avatar_url":"https://avatars.githubusercontent.com/u/2053478?v=3","gravatar_id":"","url":"https://api.github.com/users/christopherthielen","html_url":"https://github.com/christopherthielen","followers_url":"https://api.github.com/users/christopherthielen/followers","following_url":"https://api.github.com/users/christopherthielen/following{/other_user}","gists_url":"https://api.github.com/users/christopherthielen/gists{/gist_id}","starred_url":"https://api.github.com/users/christopherthielen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christopherthielen/subscriptions","organizations_url":"https://api.github.com/users/christopherthielen/orgs","repos_url":"https://api.github.com/users/christopherthielen/repos","events_url":"https://api.github.com/users/christopherthielen/events{/privacy}","received_events_url":"https://api.github.com/users/christopherthielen/received_events","type":"User","site_admin":false},"milestone":null,"comments":18,"created_at":"2016-01-25T23:33:10Z","updated_at":"2016-02-01T21:26:11Z","closed_at":null,"body":"This fiddle shows the difference in order of $destroy and $stateChangeSuccess between 0.2.15 and 0.2.16\r\n\r\nhttps://jsfiddle.net/n3emkeo7/\r\n\r\nThis change broke our application, and I think it could be quite a significant breaking change.\r\n\r\nMy guess is that it's something to do with 1be13795 (unconfirmed).\r\n\r\nOur use case:\r\n\r\nWe have a navigation control which listens for `$stateChangeSuccess` and subsequently updates the URL using `$state.go`.\r\n\r\nIn 0.2.15 this was fine if you navigated to a different page, the navigation control was destroyed before the `$stateChangeSuccess` event was fired, so the control would only redirect the user if they were navigating to a child state.\r\n\r\nIn 0.2.16 the `$stateChangeSuccess` event is fired before the control is destroyed, causing the user to be trapped on the page with the navigation control regardless of if they are trying to navigate away from the page."},"comment":{"url":"https://api.github.com/repos/angular-ui/ui-router/issues/comments/178201509","html_url":"https://github.com/angular-ui/ui-router/issues/2485#issuecomment-178201509","issue_url":"https://api.github.com/repos/angular-ui/ui-router/issues/2485","id":178201509,"user":{"login":"ledhed2222","id":7291533,"avatar_url":"https://avatars.githubusercontent.com/u/7291533?v=3","gravatar_id":"","url":"https://api.github.com/users/ledhed2222","html_url":"https://github.com/ledhed2222","followers_url":"https://api.github.com/users/ledhed2222/followers","following_url":"https://api.github.com/users/ledhed2222/following{/other_user}","gists_url":"https://api.github.com/users/ledhed2222/gists{/gist_id}","starred_url":"https://api.github.com/users/ledhed2222/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ledhed2222/subscriptions","organizations_url":"https://api.github.com/users/ledhed2222/orgs","repos_url":"https://api.github.com/users/ledhed2222/repos","events_url":"https://api.github.com/users/ledhed2222/events{/privacy}","received_events_url":"https://api.github.com/users/ledhed2222/received_events","type":"User","site_admin":false},"created_at":"2016-02-01T21:26:11Z","updated_at":"2016-02-01T21:26:11Z","body":"Out of curiosity, I'm not quite sure how I WOULD refactor my code to better initialize controllers. The 'resolve' element works great for passing data into a controller, but I'm not sure how to run initialization procedures when switching between child states, without resorting to $stateChangeSuccess.\r\n\r\n@christopherthielen or @nateabele, what is the ideal way to handle initialization of a controller upon state changes that share the same controller?"}}