All we need is an easy explanation of the problem, so here it is.
In a single-page application that uses Angular, it seems like most of the things are handled on the client-side. The client seems to just make restful calls to the server.
Following this concept, it seems to me that my server-side will not have any application at all, but only scripts that generate RESTful json data for the client to read.
Perhaps frameworks like Hibernate or those that connects to the database are still relevant since the restful scripts on the server are going to still have to connect to the DB. But what about those MVC frameworks?
Since in a single-page app the server is only required to serve RESTful calls for the client, frameworks such as Spring, Struts (in Java) or Laravel (in PHP), etc, they all are not relevant to SPAs? Which means the server side will probably just need a good RESTful library that we can work with to serve the json data and that’s all? Otherwise, what would the views and controllers be on the server in a SPA?
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
I think that the MVC frameworks are still useful into an SPA application. I am developing a SPA application, and I am using ASP .NET MVC for two things:
To Manage the first page of my application. It allows me to make use of the advantages of this framework such as the facilities for managing joining and minification of scripts.
To return the partial views that I am using in Angular. It allows me to use the razor templating, and also to manage how the partial views are catching.
I think that you can get some advantages if you mix the two things.
I hope that it helps.
if your view and navigation logic its in the client and your server “only” needs to respond to HTTP call (RESTfull probably), what things do you need on the server side:
- A way to map urls with server services.
- A way to produce a json (or perhaps other formats) output.
- Your regular business logic and data-access logic if you need, this its the same that always.
Probably with a good Rest framework like jersey its more than enough, i’m playing a bit with dropwizard (http://dropwizard.codahale.com/) and by the moment i’m really happy with this simple framework.
It is still relevant, however, the view in that case is the mechanisms, producing JSON/XML and it can be implicit.
Spring REST in that case with the underneath controllers is the an example of such. You still need your Application Services will still manipulate on the Model that you will get from some sore of persistency mechanisms, accessed through DAOs.
The architecture is the same, just the data representation in the view is different.
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂