I have a single Angular 13 application with 1 module. It is a conversion from an old project that had 3 applications. The 3 applications have separate urls that are accessed through .jsp files that then should route to 3 different routes within the now single Angular application.
The jsp files have a redirect as below:
response.sendRedirect("../angular-application/index.html");
However, I since I need them to direct to separate pages, I tried:
response.sendRedirect("../angular-application/support.html");
then in my app.module.ts file: I attempted to implement a similar switch statement to what was found here: Angular 6 - multiple Entry points
import {ApplicationRef, DoBootstrap, NgModule} from '@angular/core';
@NgModule({
entryComponents: [AppComponent, SupportComponent],
declarations: [
AppComponent,
SupportComponent
],
//bootstrap: [],
}]
export class AppModule implements DoBootstrap{
ngDoBootstrap(appRef: ApplicationRef) {
switch ((<any>window).Mode) {
case 'index## Heading ##':
appRef.bootstrap(AppComponent, 'app-root');
break;
case 'support':
appRef.bootstrap(SupportComponent, 'app-support');
break;
}
}
This doesn't work to render any of the pages. I changed window.Mode to window.name, setting the window name in the html page and was able to route to index.html, however I am having issues with the routing to the other pages. First, and probably an easy solution I just don't know about, if I try to access the page through any of the other html files in the src folder, they are not recognized, and are treated as if they are index.html. I declare window.name as "support", but when I debug in the console, it says window.name is "index" as I set it in the index.html file. Second, when I use the debugger and change the variable in the console to match the other cases, I get the error: "Error: The selector "app-support" did not match any elements".
I am open to other solutions to this as well, aside from using the multiple entryComponents. I cannot change it to 3 applications though.
Other thoughts I had were sending data through the .jsp files on the redirect and writing a script with an if statement to navigate to the appropriate component through the index.html file, however I have not found any information on how to accomplish that from a .jsp file.
Any help to resolve this is very appreciated.