My first choice was Backbone JS since that appeared to be a popular framework and a nice evolution from MVC frameworks such as Sproutcore. My app was really simple. Show a couple of pages with one that has JSON data that will be periodically read from a server and updated as a whole set. There is no data editing, no crazy data synchronization etc.. My requirements were a bit different than most examples that are out there. Most of the examples are using exclusively LocalStorage or a remote Restful API or are using some carefully designed data elements with id’s etc. that can be sync’d. I’m sure that if I had spent enough time with Backbone I would have figured out a solution to this, but there didn’t appear to be anything in it that readily supported this scenario. That is on top of the complication with figuring out which templating technology to use and how to wire everything together. And then there is testing which doesn’t seem to have great support in this framework.
For example if I have a data object called person that has a name. In Ruby the view would look something like this.
Name: <%= @person.name %>
In the angular view template (which are very similar to erb’s) your code would look like this
Angular also has a pretty straight forward routing system, can do two way binding of objects in the view and has testing built in.
Now I haven’t tried this with Coffeescript yet, but that would be the ultimate. There may be some gotcha’s with the framework on a more complex project, and it is a opinionated framework, but for my money I am sold. It forces you into good habits in your view, enforces the right behavior and is simpler to use.
Leave a Reply