2

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.

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

so in my case, base path in index.html is as <base href="/"> Do you want to add something else? Also I do not see main bundle.js file after build
1

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.