HTML as an application language
Web development in 2010 is split between two approaches: traditional server-rendered pages, where every interaction requires a full reload, and applications built with jQuery that manipulate the DOM manually, with code that quickly becomes unmanageable as complexity grows. AngularJS, released by Google as an open source project, proposes a third path: transforming HTML from a static markup language into a declarative language for web applications.
The idea originates from the work of Miško Hevery and Adam Abrons. Hevery, an engineer at Google, demonstrates internally that a project requiring weeks of development with traditional approaches can be rewritten in a fraction of the time using his framework. Google decides to support the project and release it publicly.
Two-way data binding
The central concept of AngularJS is two-way data binding: an automatic, bidirectional connection between the data model (JavaScript) and the view (HTML). When the user modifies an input field, the model updates automatically; when the code modifies the model, the view updates accordingly. There is no need to write code to manually synchronise the two layers.
This mechanism relies on a digest cycle that compares current values with previous ones and propagates changes. For applications with complex forms — typical of enterprise contexts — the code savings are significant.
Directives, services and dependency injection
Directives are the mechanism through which AngularJS extends HTML. Custom attributes such as ng-repeat, ng-model and ng-show add dynamic behaviours directly in the markup, making the template readable as a description of the interface rather than a sequence of DOM manipulations.
The architecture is completed by services — singleton objects that encapsulate business logic, HTTP calls and shared state — and by dependency injection, a pattern where components declare their dependencies and the framework provides them automatically. Dependency injection facilitates testing: any service can be replaced with a mock during unit tests.
AngularJS also introduces the concept of a Single Page Application (SPA) into the mainstream: a single HTML page that dynamically loads views without reloading the entire page, handling routing on the client side.
Enterprise patterns in the browser
AngularJS brings to the browser patterns well established in server-side development — MVC, dependency injection, separation of concerns — offering an opinionated structure where every element has a precise role. The framework is released under the MIT licence.
Link: angularjs.org
