You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we use the visualiser, we can see that states declared on any NgModule are not loaded. But when we navigate to an ng1-declared state which uses an ng2 component, all the NgModule-declared states then appear. Can't work out why...
Both UIRouterModule.forChild() and Ng1ToNg2Module declare an NgModule with stuff in it. However, it doesn't implicitly instantiate anything from those modules. If you never inject anything that depends on the ng2 UI-Router (for example, a component that uses a UIView or uiSref), ng2 DI never instantiates anything from the forChild() module, so the routes don't get registered.
We need to inject something ng2 for UIRouter
Try this:
Call deferIntercept() on $urlRouterProvider (tell ui-router not to check url until you're ready)
Add a .ready() to your ngUpgrade bootstrap which:
Gets UIRouter class for ng2 from the injector
Calls listen() and sync() on the $urlRouter
functionreadyFn(ref: UpgradeAdapterRef){// Causes ng2 ui-router bootstrap to happenref.ng2Injector.get(UIView);// geta an ng2 class to trigger DIlet$urlRouter=ref.ng1Injector.get('$urlRouter');$urlRouter.listen();$urlRouter.sync();}upgradeAdapter.bootstrap(document.body,[...]).ready(readyFn);
This is conceptually similar to ng1 inject in a run() block like so:
Only states from a lazy loaded module are registered. States in the NgModule being bootstrapped are not registered.
The text was updated successfully, but these errors were encountered: