Why I Prefer AngularJS vs. KnockoutJS

Wednesday, April 30, 2014 11:15 AM

Whoa… hold on a second there! That’s the wrong question to ask. Why? Let’s back up a bit…

I get this question a lot from people who are looking to building single page apps (SPA) or just your standard client-side solutions. Last week I presented a SPA session at the SPTechCon conference in San Francisco and also had my latest course on Pluralsight released, Building SharePoint Apps as Single Page Apps with AngularJS. Where is it coming from? Well for a while now many folks have heard of KnockoutJS and used it for data binding solutions in the client. While it’s a bit older than a year, in the last 12 months we have seen dramatic growth in the community around the Google-backed AngularJS platform. As such, many people ask “which one should I use? Angular or Knockout?”

This isn’t an uncommon question… a quick search for angular vs. knockout will yield tons of results. There’s a great discussion on StackOverflow about it as well as a good dialog on Quora too

On the surface, it makes a lot of sense to ask that question, but in reality you are trying to compare a screwdriver to a toolbox. What do I mean by that? Well, Knockout is simply a data binding framework & a every good one at that. But Angular is much much more than just data binding. Angular also offers routing/navigation support, the async module loading (AMD) pattern, services for working with network calls like REST services and the cookie store to name a few not to mention it’s own data binding framework.

The question isn’t so much as if you would use Angular vs. Knockout. The questions you should ask yourself should start with “do I need data binding or do I need a SPA presentation framework.” If you aren’t building a SPA, I offer that Angular is way too much for what you need… if all you need to do is tighten that doorknob, you just need a screwdriver, not the whole toolbox. But if you are making a new door to mount in a gap in the hall, you’ll need your whole toolbox with not only screwdrivers, but drills, hammers, sanders, levels… all sorts of tools.

A more fair comparison to Angular would be DurandalJS which is a full-blown SPA presentation framework like AngularJS. Unlike AngularJS, Durandal uses Knockout for it’s data binding solution as well as other libraries you’re familiar with like RequireJS (for the AMD pattern), q for async promises and jQuery for all your cross browser and selection support.

Hope that clears up that question. Also check out John Papa’s take on this: Compare Durandal to Angular, Not Knockout to Angular who makes a similar point in his own words.

Finally, here are a few references that might help in evaluating your next JavaScript framework, as well as trying to decide which one you want (some I think make the wrong comparison of Angular to Knockout, but it does show how the data binding pieces are different:

comments powered by Disqus