WHEN I implement a custom ngDoBootstrap
function instead of the default bootstrap: [AppComponent]
like shown below:
@NgModule({
imports: [ BrowserModule, FormsModule, AppRoutingModule ],
declarations: [ AppComponent, HelloComponent ],
exports: [ AppComponent ],
entryComponents: [ AppComponent ],
// bootstrap: [AppComponent],
})
export class AppModule {
constructor(private injector: Injector) {
}
public ngDoBootstrap(): any {
const appElement = createCustomElement(AppComponent, { injector: this.injector });
customElements.define('my-app', appElement);
}
}
THEN The application routing experiences issues.
It fails to respond to changes in the URL and only functions correctly when clicking on <a [routerLink]='...'>
. Additionally, the initial route / is not loaded as expected.
This issue seems to stem from the custom bootstrap mechanism, as uncommenting the bootstrap: [AppComponent]
resolves the problem.
You can access the full code here: stackblitz sample (requires downloading and running locally due to the TypeScript version used by stackblitz)
Any suggestions on how to ensure proper routing with a custom app module bootstrapping?