Services/Provider config surviving app teardown #9877
Description
I'm trying to chase down a very elusive bug, and I'm not sure exactly where it's occurring. Heres the setup:
The application is a game client, which is separated into two stages, both written as separate angularjs applications. The first stage is the login screen, and is comprised of a handful of pages, managed using ui-router. When the player logs in, the first stage creates a new module with the session information, asynchronously loads the second stage js from the server, unloads itself by removing the DOM element, and bootstraps the second stage, which is the actual game client. This is done with the following code:
setTimeout(function() {
angular.element(document.getElementById("loginSide")).remove();
$rootScope.$destroy();
angular.bootstrap(document.getElementById("gameSide"), ['client.game']);
}, 0);
I put this in a setTimeout to get out of the $apply scope of the first stage. The $rootScope refers to the first stage. This second stage also uses ui-router. This mostly works, with one major exception: the state configuration from the first stage has somehow survived, and is being applied to the second stage. Specifically, $urlRouterProvider and $stateProvider configuration in stage 1 still affects stage 2.
I don't know if this is intended behaviour, a bug in angularjs, or a bug in ui-router, which is why I created an issue in both. I'm on angularjs version 1.3.0, and ui-router 0.2.11. Thanks