Blog

Follow the latest thinking from people working at the cutting edge of innovation and have your say on everything from economic policy to robot overlords.

AngularJS vs KnockoutJS

by Tayyab

Posted on

angularjs-vs-knockout | Code Desk

KnockoutJS

Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model. Any time you have sections of UI that update dynamically (e.g., changing depending on the user’s actions or when an external data source changes), Knockout can help you implement it more simply and maintainable.

Features

  • Elegant dependency tracking – automatically updates the right parts of your UI whenever your data model changes.
  • Declarative bindings – a simple and obvious way to connect parts of your UI to your data model. You can construct a complex dynamic UIs easily using arbitrarily nested binding contexts.
  • Trivially extensible – implement custom behaviors as new declarative bindings for easy reuse in just a few lines of code.
  • Pure JavaScript library – works with any server or client-side technology.
  • Can be added on top of your existing web application without requiring major architectural changes.
  • Compact – around 13kb after g-zipping.
  • Works on any mainstream browser (IE 6+, Firefox 2+, Chrome, Safari, others).
  • Comprehensive suite of specifications (developed BDD-style) means its correct functioning can easily be verified on new browsers and platforms.

AngularJS

Angular JS is a new, powerful, client-side technology that provides a way of accomplishing really powerful things in a way that embraces and extends HTML, CSS and JavaScript, while shoring up some of its glaring deficiencies. It is what HTML would have been, had it been built for dynamic content.

Features

1. Two Way Data-Binding

Data-binding is probably the coolest and most useful feature in AngularJS. It will save you from writing a considerable amount of boilerplate code. A typical web application may contain up to 80% of its code base, dedicated to traversing, manipulating, and listening to the DOM. Data-binding makes this code disappear, so you can focus on your application.

2. Templates

In AngularJS, a template is just plain-old-HTML. The HTML vocabulary is extended, to contain instructions on how the model should be projected into the view.

The HTML templates are parsed by the browser into the DOM. The DOM then becomes the input to the AngularJS compiler. AngularJS traverses the DOM template for rendering instructions, which are called directives. Collectively, the directives are responsible for setting up the data-binding for your application view.

3. MVC Design pattern

AngularJS incorporates the basic principles behind the original MVC software design pattern into how it builds client-side web applications.

The MVC or Model-View-Controller pattern means a lot of different things to different people. AngularJS does not implement MVC in the traditional sense, but rather something closer to MVVM (Model-View-ViewModel).

Dependency Injection

AngularJS has a built-in dependency injection subsystem that helps the developer by making the application easier to develop, understand, and test.

Dependency Injection (DI) allows you to ask for your dependencies, rather than having to go look for them or make them yourself. Think of it as a way of saying “Hey I need X’, and the DI is responsible for creating and providing it for you.

Directives

Directives can be used to create custom HTML tags that serve as new, custom widgets. They can also be used to “decorate” elements with behavior and manipulate DOM attributes in interesting ways.

Comparison

Detail AngularJS KnockoutJS
Description Toolset for building the framework most suited to your application development Simplify dynamic JavaScript UIs by applying the Model-View-View Model (MVVM)
Tag Javascript Javascript
Extension/Plug-in Yes Yes
Template language Html5 Html5/Any you want
Adobe Flash Support No Yes
Multi tasking Yes No
RESTful Conditional Yes
Jquery Support Yes Yes
Object-Relational Mapping (ORM) Yes No
Client/Server code reuse Model-View-Controller(Web services) Model-View-Controller
Browser support Internet Explorer9+.Firefox.Chrome.Opera. Chrome.Firefox.Internet Explorer.Maxthon(browser).Opera.Safari
Real Time Yes Yes
Websocket Support Yes Yes