1

I have built a new Angular7 application and locally angular application is working fine. Now I need to launch my angular application from the existing legacy web application which is build on Java/JSP. In the existing legacy application, I have a URL. On click of that URL, angular application should open.

But whenever I am hitting the URL, seems like routing is not happening properly to angular app.

Local angular application is running successfully on - http://localhost:4200/alerts;alerttype=renewals;cor=411119

What I did so far, I have copied the angular dist folder to the webcontent folder of legacy application and running the application as below

http://localhost:9086/customer/eWeb/AlertApp/alerts;alerttype=renewals;cor=411119

app.routing.module.ts

    const routes: Routes = [
    { path: 'alerts', component: AlertsComponent },
    { path: 'customer/eWeb/AlertApp/alerts', component: AlertsComponent 
     },
    ];

Can anyone help and tell how to launch the angular application from the legacy application? what all routing needs to be configured?

Thanks in advance.

MSV
  • 155
  • 2
  • 16

2 Answers2

0

Once you build your angular application, you get a few js and css files (depending upon your code, mode details here)

Just bundle and move these files on the server and call the main file (bundle.js) on a JSP page.

Before doing this, don't forget to set the base path in index.html

Saksham
  • 9,037
  • 7
  • 45
  • 73
  • so in my case, base path in index.html is as Do you want to add something else? Also I do not see main bundle.js file after build – MSV Jun 17 '19 at 21:38
0

Update your server-side url config (SpringMVC or SpringBoot config or Servlet web.xml) to return your parent jsp.

http://localhost:9086/customer/eWeb/AlertApp --> app.jsp

In app.jsp, just include css + bundled js files (similar your angular index.html)

<body>
 <div app> </div>
 <script type="text/javascript" src="runtime.js"></script><script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="scripts.js"></script><script type="text/javascript" src="main.js"></script>
</body>
Ethan Nguyen
  • 104
  • 4