Having a self-contained application is a good start, but in a real SPA application it will need to manipulate data. In order for a SPA to get data it needs to communicate to the server and receive a session token that will provide the authentication to further data calls. This means that the SPA is an empty shell of views and controllers. What we need to do now is make requests to the server to get data and bind it to the variables within the views. In part six (6), we will look at the security aspects of SPA data calls, but for now we are focused on the calls themselves.
- these calls are centered around the function (need) of the call, and does not perform an SQL query directly
- the data has a defined schema
In order to have a clear path of development, we will focus on the three main steps for us to get data into the application. These are:
- From the function, call a database and return the results via JSON to the SPA
- Bind the data from the call into the AngularJS variable
The code in this example can be found on github. Like the previous skeleton, this is very simple. Over the next couple of blogs, I will add security to the calls and clean up the hierarchy in the view structure. These changes, as the blog continues, are normal to Angular apps as they get more complicated.