r/programming • • Mar 18 '14

AngularJS 2.0

http://blog.angularjs.org/2014/03/angular-20.html
213 Upvotes

71 comments sorted by

View all comments

9

u/passwordissame Mar 18 '14

did everyone move away from AJAX as in server responding with (x)html/xsl and client applying those to update DOM?

looks like it's all JSON and manual DOM manipulation.

26

u/nick_giudici Mar 18 '14

Yes, the industry has moved that way. It's been found to be a better separation of concerns. The server deals with data and the client deals with presentation of that data. Specifically, what if you want to use the same server back end to drive a native mobile app as well as your site? That xhtml response from the server just became a bit of a liability vs a simple and direct data response.

Also, it's common to use html templates like handlebars or underscore to make this easier. That way you have your html template stored in an html file. You can compile the template and reuse it. Each response from the server can just get fed into the appropriate template and it's very automated and clean.

2

u/[deleted] Mar 18 '14

It's been found to be a better separation of concerns

Ya know, it sure would be nice if someone with a CS degree or a CS prof would write an article with clear logic and reasoning to support that argument. Using the blanket "we split things into different modules therefore we separated our concerns" doesn't inspire confidence.

Specifically, what if you want to use the same server back end to drive a native mobile app as well as your site? That xhtml response from the server just became a bit of a liability vs a simple and direct data response.

I've used angularjs on a project and we ended up with an API just for angularjs and an API for other clients to consume. So that "liability" is going to exist in any case. Sure the angularjs-specific API is also JSON but it's not made for other clients to use.

3

u/dnissley Mar 18 '14

Why did you end up splitting your api just for angular?

2

u/[deleted] Mar 18 '14

Efficiency and client demands.