I love AngularJS, you should too
On a recent project for Confused.com Fresh Egg was asked to build an SPA (Single Page Application) to provide users with local school and house price information from various web services and data points (the tool is embedded further down the page).
Without hesitation, I went straight to my toolbox and took out AngularJS, and here are the main reasons why:
Write less do more!
It’s made by Google
Angular has been developed and maintained by a dedicated, highly-talented group of Google engineers since 2009. So you can be sure that you're working with a comprehensive, efficient and reliable code that will lead to quicker and more modular front end development.
In order to deliver the Confused.com project on time, it was essential for different teams to work on different aspects of the web app concurrently. AngularJS made this easy with its use of the Model-View-View-Model (MVVM) pattern. This enabled us to maintain a clean separation between the applications logic and the user interface.
Restful functions are easy
Working with restful APIs is common practice, and anything that speeds up the repetitive coding to make calls to the services is good in my books. By using the built in $http service, communication with the remote HTTP server is easily facilitated.
One of the things I love most about AngularJS is the way you can extend HTML to serve it semantically. Before if you want a Google Map on the page your HTML would look something like: <div class=”my-points”></div>. In the Angular world your HTML would look like this <googlemap></googlemap>. As you can see, it’s much easier for the front-end developer, or anybody else working on the project, to understand the code’s purpose. This also removes the reliance on IDs and classes to locate elements and perform tasks, which means the styling can be freely changed whenever required.
Another great out-of-the-box feature is filters, which can be used to filter data before getting to the view. This works by selecting a subset of items and returns a new version, with your filters applied.
Filters come in two flavours: there are the standard built in filters and, as you would expect, the custom versions.
AngularJS is reusable
AngularJS enables you to create small, manageable chunks of code that you can test and reuse independently of one another.
HTML wasn’t designed for the increasingly dynamic web of today, and while there are alternative frameworks available, I find that none of them quite address this issue as well as AngularJS.
Interested in learning more?
- Dan Wahlin’s AngularJS Fundamentals In 60-ish Minutes is a good place to start
- I can also recommend Code Schools free course, which gives lessons via a series of screen casts and challenges
- Also, the main AngualrJS site has a wealth of tutorials and information