Monday, January 28, 2013
So here's a small but completely functional application written using Angular and Twitter bootstrap. In less that 70 lines of code I managed to access LastFM's APIs and show the list of top artists by country returned from the service. From there we can navigate to see the top albums for each artist and the top tracks. Can you do that as easily with other frameworks? Maybe, but doing it with Angular was easy and fun. I really recommend AngularJS to anyone looking to develop a web based interface.
So what does the code look like?
In angular you start off defining your modules, some factories or/and services and configuring which URLs will trigger which controllers. You also define which templates will be used when a controller is triggered.
Angular provides nice AJAX abstraction in the form of a $resource service that provides means to interact with RESTful server-side data sources. And now for the controllers:
As usual here's the app in action on Heroku and the whole source code.