Thomas Thomas - 2 months ago 20
Node.js Question

angularJS problems on tomcat - application restarts on page/controller-change

For my local angularJS development, I'm using nodeJS. If I deploy my angularJS project on a tomcat server, it basically works BUT, I'm using different pages and different controllers and every time I click on the other page, it seems that the whole application is restarted again, because the data in the rootscope is lost and it starts program parts which should be started on application startup only.

Can anybody tell me whats going wrong here?
Why is my application not 100 % correct running on tomcat?

I'm using tomcat 7.0.34

Answer

I'm not familiar with Tomcat, but we've had the same issue with Apache. As Angular needs to do the routing of your app itself, you have to tell your web server to always deliver your root HTML page, e.g. index.html.

After doing that, your app should work fine.