Kayavak / The Web Frontend / FE·23 Angular / Deeper
Deeper · The Web Frontend
Angular
The questions the chapter doesn't stop for: why this exists, the model to keep in your head, what changes when an assumption does, how sure we are of each claim, and what's still open. Read it after the chapter; back to the chapter.
Why does this exist?
AngularJS (Miško Hevery and Adam Abrons, 2009–10, then Google) made two-way data binding mainstream: change the data and the page updated, type in a field and the data changed. It ran a "digest cycle" that re-checked every binding until nothing changed, which became slow and unpredictable in large apps. Google rewrote it from scratch as Angular (2016), in TypeScript, with components, dependency injection, ahead-of-time compiled templates and RxJS observables, aimed at large enterprise teams. The rewrite was incompatible, which upset many AngularJS users.
Angular then evolved in steps rather than rewrites. The Ivy compiler (default in Angular 9, 2020) made templates compile to smaller, faster instructions. Standalone components removed the need for NgModules. Signals (from Angular 16, 2023) introduced fine-grained reactivity, which lets Angular drop Zone.js, the library that patched every browser API to know when to check for changes.
The mental model
Try it yourself first: write your own model in the Mental Model Explorer, then compare.
Angular is a full framework with opinions: components and templates for the view, dependency injection for services, and a change-detection system that decides when the view must be refreshed, increasingly driven by signals.
| Question | Answer |
|---|---|
| What is it? | A batteries-included framework: components, templates, DI, routing, forms, HTTP, testing and a CLI |
| Problem it solves | Building large applications with many developers in one consistent structure |
| Parts | Components and compiled templates, signals and RxJS, injectors and services, router, forms, change detection |
| How it works | The compiler turns templates into update instructions; when state changes, change detection runs those instructions for affected components |
| Assumptions | Teams follow the framework's conventions; data flows through signals or observables Angular can see |
| When they change | Mutating objects behind Angular's back, with OnPush or signals, leaves the view stale |
| Where it fails | Heavy for small sites; RxJS has a steep learning curve |
| Related ideas | Dependency injection (Software Architecture); signals vs diffing (ch21); TypeScript (ch16) |
What if?
What if Angular checked every binding after every event, as AngularJS did?
Reason it through, then open
Every click, timer and network response would re-evaluate every expression on the page. Small apps wouldn't notice; large ones would spend most of their time checking bindings that hadn't changed. OnPush change detection and then signals let Angular check only components whose inputs or signals actually changed.
What if there were no dependency injection?
Reason it through, then open
Each component would create its own services (new HttpClient(...) with all its configuration), so tests couldn't
swap in fakes and two components couldn't share one instance. DI makes "give me something that can do X" the default
and lets the application decide what X is: one instance per app, per route, or per component.
Where the boundary is
| Aspect | Signals | RxJS observables |
|---|---|---|
| Represents | A value that changes over time, always readable now | A stream of events over time |
| Read | Synchronously, count() |
By subscribing |
| Good for | State shown on screen | Async workflows: debounce, retry, cancel, combine streams |
| Bridged by | toSignal / toObservable |
How sure are we?
| Claim | How it's known | Where from |
|---|---|---|
| AngularJS (2010) and Angular (2016) are different frameworks | Historical | Google's announcements; no upgrade path except migration |
| Ivy became the default renderer in Angular 9 | Historical | Release notes, 2020 |
| Signals reduce change-detection work | Model | True by design; size of the gain depends on the app |
| Angular suits large teams | Model | Widely held, based on its conventions; not measured in controlled studies |
Still open
Angular's move to signals and away from Zone.js is changing what idiomatic Angular code looks like, and how much RxJS remains central is being worked out in the community.
What would change your mind? If small teams built and maintained Angular apps as cheaply as with lighter libraries, the "large teams" framing would be out of date.
Recall
Why did AngularJS's digest cycle become slow?
It re-checked every binding repeatedly until nothing changed, after every event.
What did dependency injection give Angular apps?
Shared, configurable service instances and easy substitution in tests.
When are signals a better fit than observables?
For state that has a current value shown on screen; observables suit event streams and async workflows.
What did Ivy change?
How templates compile: into smaller, faster instructions, default from Angular 9.
Reflect
Be honest with yourself; this stays in your browser. Anything you can't tick yet is what to revisit.