I am building an online social network. I have finished writing RESTful API service using Django. This will return only JSON response (No HTML will be generated from server side) so that this JSON response can be used to build native smartphone apps. API service being common to all clients.
My question is, since there is no HTML response from server side, can the MV* Javascript Frameworks like Angular / Backbone / Ember take care of complete Front-end, right from generating HTML page with CSS?
3 Answers 3
Yes definitely a MV* framework will work for you.
I am already working on a project where we use Zend framework's REST API which throws only JSON data and BackboneJS on the client side for generating and rendering the HTML content.
BackboneJS I would suggest. Alternatively AngularJS would be a very good option as it allows dynamic binding and easy MODEL - VIEW and VIEW - MODEL binding i.e. binding in AngularJS is both ways.
Yes to any of the MV* frameworks. All of them were designed to work with a REST API. Those frameworks will take the JSON data returned from the REST service, store it in memory on the client, and also use that data to generate the HTML.
A good sample app for using a Rest API with Backbone/Angular a couple of friends and I put together can be found up on Github. It doesn't do a whole lot, but it should be a good place to start. The App is written in ASP.NET MVC, but all the UI (specifically the angular section) is straight HTML/CSS. You can easily pull that piece out into a seperate project and everything would still work.
Yes, popular MVC framework like AngularJS/Ember works for you.
AngularJS framework gives greatest advantage of TWO WAY binding, it means that any change in MODEL will automatically get changed in VIEW and vice verse.
Mainly AngularJS is for Data binding, it takes complete care of calling web api and binding data with concerned html elements.
And for generating HTML which can be easily done creating angularJS directive, which makes your application clean , neat and maintainable code.
Lastly for CSS you can use bootstrap 3 , which has inbuilt in classes for responsive UI design for all type of devices.
Hope this helps for you.
Explore related questions
See similar questions with these tags.
can the MV* Javascript Frameworks like Angular / Backbone / Ember take care of complete Front-end?
Yes they can. Call you web serive APIs using AJAX and use the returned JSON to create UI (using HTML, JS/ CSS).