New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RouterModule does not initialize correctly when using UpgradeModule #14081
Comments
To unravel the issue one step further, it seems that in this case, the application bootstrap listeners (APP_BOOTSTRAP_LISTENER) are not invoked at all. Which kind of makes sense, since with the UpgradeModule, we're running an NG1 application. On the other hand, it's not what various NG2 components, including the RouterModule, expect. Calling the listeners manually still doesn't fix the issue, the ApplicationRef is still not correctly set up then. |
Could you create a minimal, runnable demo. It is hard to investigate this without a reproduction. |
I'm about to leave for my christmas holidays, but the following looks close to what I had back in January and exhibits similar symptoms: |
It turns out that I am not sure what the reasoning is for not running import {..., setUpLocationSync} from '@angular/router/upgrade';
...
@NgModule({
imports: [ ... ],
providers: [
{provide: UrlHandlingStrategy, useClass: CoexistingUrlHandlingStrategy},
],
declarations: [ ... ],
entryComponents: [ ... ],
})
export class AppModule {
constructor(private upgrade: UpgradeModule) {}
ngDoBootstrap() {
this.upgrade.bootstrap(document.body, ['old'], {strictDi: true});
setUpLocationSync(this.upgrade);
}
} |
I'm submitting a ...
Current behavior
initialRouterNavigation
(from upgrade.ts) is not called during bootstrap. As a consequence, RouterModule does not navigate to the initial URL, and does not subscribe to location changes caused byngRoute
, causing it to not deactivate a route when navigating to a route managed byngRoute
.Expected behavior
initialRouterNavigation
is invoked, the RouterModule navigates to the initial URL, subscribes to location changes caused byngRoute
and deactivates the current route whenngRoute
changes location.Minimal reproduction of the problem with instructions
I have been trying to follow the approach documented at @angular/router/upgrade.ts:
main.ts:
app.module.ts:
Please tell us about your environment:
Browser: all (verified in Firefox and Chrome. Bootstrapping issues are probably not browser related)
Language: TypeScript
The text was updated successfully, but these errors were encountered: