all about angularjs

All About Angularjs: Pros and Cons of Google’s Web-App framework

AngularJS calls itself a Superheroic JavaScript MVW Framework.

Don’t scoff with derision.

With over 300,000 websites using this tool (at the time of writing), a rapidly growing community that just loves to give, and the unique way it rolls (it’s full of cocky self-assurance with lines like “teaches your browser a new syntax” or “this is what HTML should be”) one has to wonder if it’s really worth the hype. I mean, jQuery works, right?

Contentment is the enemy of development: quite literally for us developers. Angular sounds self-confident because it has every right to be. But don’t take my lone word for it. Check out what makes Angular awesome and awful and see if you agree with me.

Here goes:

The Pros:

Angular is extremely efficient when it comes to:

  1. Automatic DOM Manipulation

Updating model from view and updating view from model is no longer your (read: developer’s) responsibility. With two-way data binding, DOM manipulation is automated and you need not fret.

2. Trials and testing

This is what I adore about Angular: The rigorous refactoring and debugging. Dependency injections replace main() and the unpardonable mess it made (think maintenance issues). Testing is not just made easy but encouraged with unit-testing tool (Karma) and end-to-end testing tool (Protractor).

3. The Separation of Concerns

Logic is comprehension, and MVVW design paradigm has a comprehensible logic that’s great to work with. Simply put, the $scope (here: viewmodel) references the data, controller decides (or ‘controls’) its behavior, and your front end skills take care of the view.

4. Leaner, friendlier SPA Development

We know Angular and AJAX are best of chums and work amazingly well together for SPA (Single Page Application) development. But it goes way beyond AJAX with Angular.

It has built-in ngRoute module [note: requires angular-route.js to work] that makes deep linking (lets your users bookmark and save a SPA for later viewing) simpler. It lets you declare inline validation rules without having to write JavaScript. If that isn’t awesome, I really don’t know what could possibly be.

5. The Filters

This is one irrefutable plus, especially for developers working on content management systems who would rather bite their toenails than spend time writing client-side JavaScript.

For instance, using the legendary WordPress API, I can get JSON files of my data (read: posts, users, taxonomies, etc.) on an established WordPress site which needs a thorough, but speedy, revamp. I can then give it the makeover it needs with Angular, if I know what I’m doing.

Which actually brings us to…

The Cons:

1. The Learning Curve

This is at the core of every single pros/cons list-icle on AngularJS, and I may get some flak for this since I used to find it difficult too, but it looks more intimidating than it actually is.

All the syntax you and the browser have to learn in order to work with Angular is enough to make someone break out in sweat, at first glance. But as someone on Reddit once said, the ‘perceived complexity’ of Angular is far more than the reality.

Nevertheless, it does have a very weird learning curve. Ben Nadel sums up the feeling you get while you’re learning AngularJS superbly in one succinct blog post. The learning curve is more like a gradually scaling zigzag, rather than say, a hockey-stick.

2. Insufficient Documentation

Although it’s improving, many developers shy away from Angular because they feel the documentation does a poor job of covering up the framework properly. Since the community is still experimenting mostly and there are little-to-no official set of ‘rules’, the documentation is where people turn to find resources. If it’s lacking (I don’t think so, by the way), it puts them off.

3. Debugging Scopes

That’s one nightmare with Angular. Angular evaluates expression against scope (like JavaScript does with window. The scopes are placed hierarchically in a nested structure similar to the DOM structure of an app. Debugging them, even with the help of tools made specifically to help you visualize the nested scope structure, can be a pain.

Tl; DR

Here’s what the entire AngularJS Pros and Cons debate boils down to:

PROS:

  • Automatic DOM Manipulation
  • Better refactoring with dependency injections and rigorous unit and end-to-end testing
  • Logical paradigm: You get a neatly divided architectural structure for development.  A separation of concerns makes you work smarter and faster.
  • Great for Single Page Applications Goes a step beyond AJAX and pays due attention to elements you would say belong to UX category: inline form validation and bookmarking.
  • RESTful APIs Can be hooked easily with other systems via filters.

And CONS:

  • Learning curve
  • Insufficient Documentation
  • Scopes are hard to debug

Bottom Line

Angular JS is super efficient in the weirdest way possible (at first glance), and once you learn it, you wonder how you ever managed to work without this framework.

True story, because it’s my own.