3

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?

  • 1
    If you want HTML returned why can't you just wrap it into JSON? Or maybe you decided for the wrong tool for the task? – JensG Nov 20 '13 at 11:50
  • 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). – Aziz Shaikh Nov 20 '13 at 13:05
  • @JensG I have planned to use the same API service for building native Smartphone apps and so I do not want HTML content with response. I just want values as JSON data and use the data in html (if web) or use the data on phone apps to present it to user. – Prashere Nov 20 '13 at 14:15
  • Reasonable, and the better approach. You should edit that into the question, IMHO. – JensG Nov 20 '13 at 14:30
  • Done, I have edited the question as you suggested JensG. @AzizShaikh my concern is Social network cannot be a single page apps, but MV* JS frameworks are exceptional in doing Single Page Apps, Can they handle these things too? – Prashere Nov 20 '13 at 16:11
2

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.

2

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.

https://github.com/itsjason/OrderTracker

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.