{"action":"opened","issue":{"url":"https://api.github.com/repos/ui-router/angular/issues/322","repository_url":"https://api.github.com/repos/ui-router/angular","labels_url":"https://api.github.com/repos/ui-router/angular/issues/322/labels{/name}","comments_url":"https://api.github.com/repos/ui-router/angular/issues/322/comments","events_url":"https://api.github.com/repos/ui-router/angular/issues/322/events","html_url":"https://github.com/ui-router/angular/issues/322","id":324355201,"number":322,"title":"AngularJS: Broken lazy loaded modules on state removal","user":{"login":"realph","id":2334951,"avatar_url":"https://avatars2.githubusercontent.com/u/2334951?v=4","gravatar_id":"","url":"https://api.github.com/users/realph","html_url":"https://github.com/realph","followers_url":"https://api.github.com/users/realph/followers","following_url":"https://api.github.com/users/realph/following{/other_user}","gists_url":"https://api.github.com/users/realph/gists{/gist_id}","starred_url":"https://api.github.com/users/realph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realph/subscriptions","organizations_url":"https://api.github.com/users/realph/orgs","repos_url":"https://api.github.com/users/realph/repos","events_url":"https://api.github.com/users/realph/events{/privacy}","received_events_url":"https://api.github.com/users/realph/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-18T10:25:52Z","updated_at":"2018-05-18T10:25:52Z","closed_at":null,"author_association":"NONE","body":"I'm using ocLazyLoad in combination with [UI-Router](https://ui-router.github.io/guide/lazyloading) to lazy load my modules on state transition.\r\n\r\n    const state = {\r\n      name: 'home.**',\r\n      url: '/home',\r\n      lazyLoad = transition => {\r\n        transition\r\n          .injector()\r\n          .get('$ocLazyLoad')\r\n          .inject('home-module.ts');\r\n      };\r\n    }\r\n\r\n    $stateRegistry.register(state);\r\n\r\nThis works great. I'm able to visit that state which lazy loads `home-module.ts`, which in turn registers the components that are a part of `home-module.ts`. This all works as expected.\r\n\r\nI then want the ability to de-register that very state, and reregister the same state.\r\n\r\n    $stateRegistry.deregister(state);\r\n    $stateRegistry.register(state);\r\n\r\nIf I now revisit the `home.**` state the module is not lazy loaded and its components aren't registered. I'm trying to understand what's going on here.\r\n\r\nI have a feeling that when we deregister the state, something happens to that lazy loaded module - it's not unloaded because we cannot do that in JS. I'm guessing that the namespace (the module name) creates a pointer that references the original state name (`home.**`) and when we deregister the state, that pointer is broken. I'm out of ideas at this point.\r\n\r\nAny help on this would be appreciated. Thanks in advance!"}}
{"actor":{"display_login":"realph"}}