|
1 | | -# Learn Angular |
2 | | - |
3 | | -This repository contains a list of resources to learn Angular. It includes tutorials, articles, videos, books, and other resources to help you learn Angular from scratch. |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | -## Table of Contents |
| 1 | +# Learn Angular 🅰️ |
| 2 | + |
| 3 | +<div align="center"> |
| 4 | + |
| 5 | +[](https://opensource.org/licenses/MIT) |
| 6 | +[](https://angular.dev/) |
| 7 | +[](https://www.typescriptlang.org/) |
| 8 | +[](https://angular.dev/guide/signals) |
| 9 | +[](https://angular.dev/guide/ssr) |
| 10 | +[](https://github.com/manthanank/learn-angular) |
| 11 | + |
| 12 | +**An exhaustive, production-grade masterclass from absolute zero to staff-level Angular platform architecture.** |
| 13 | +Master standalone applications, modern Signals reactivity, `@defer` incremental hydration, hierarchical dependency injection, functional router guards, reactive forms, and zoneless performance. |
| 14 | + |
| 15 | +[Getting Started](#-getting-started) • [Standalone Components](#2-stage-2-standalone-components-templates--modern-control-flow) • [Signals & Reactivity](#3-stage-3-modern-signals-reactivity--state-management) • [Dependency Injection](#4-stage-4-hierarchical-dependency-injection--routing) • [Forms & HTTP](#5-stage-5-enterprise-reactive-forms--http-client) • [SSR & Performance](#6-stage-6-server-side-rendering-ssr-deferrable-views--performance) • [Interview Prep](#7-stage-7-staff-angular-architect-interview-handbook--cheatsheet) |
| 16 | + |
| 17 | +<br/> |
| 18 | + |
| 19 | +<a href="https://www.buymeacoffee.com/manthanank"> |
| 20 | + <img src="public/bmc-button.svg" alt="Buy Me A Coffee" width="180"> |
| 21 | +</a> |
| 22 | + |
| 23 | +</div> |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## 🗺️ 7-Stage Pedagogical Roadmap |
| 28 | + |
| 29 | +```mermaid |
| 30 | +flowchart LR |
| 31 | + S1["Stage 1: Foundations & Standalone"] --> S2["Stage 2: Components & Templates"] |
| 32 | + S2 --> S3["Stage 3: Signals & Reactivity"] |
| 33 | + S3 --> S4["Stage 4: DI & Routing"] |
| 34 | + S4 --> S5["Stage 5: Reactive Forms & HTTP"] |
| 35 | + S5 --> S6["Stage 6: SSR, @defer & Perf"] |
| 36 | + S6 --> S7["Stage 7: Staff Architect Handbook"] |
| 37 | +``` |
| 38 | + |
| 39 | +| Stage | Focus Domain | Core Concepts & Engineering Outcomes | |
| 40 | +| :--- | :--- | :--- | |
| 41 | +| **Stage 1** | **Absolute Beginner Foundations** | Standalone bootstrapping (`bootstrapApplication`), application configuration, TypeScript 5 essentials. | |
| 42 | +| **Stage 2** | **Components & Modern Control Flow** | Standalone components, `@if`, `@for (track)`, `@switch`, template bindings, content projection. | |
| 43 | +| **Stage 3** | **Modern Signals Reactivity** | Fine-grained reactivity (`signal`, `computed`, `effect`), `input()`/`output()`, RxJS `toSignal()`, zoneless change detection. | |
| 44 | +| **Stage 4** | **Hierarchical DI & Routing** | Tree-shakeable providers, `inject()` function, functional route guards (`canActivateFn`), resolvers, lazy loading. | |
| 45 | +| **Stage 5** | **Reactive Forms & HTTP Engine** | Strongly-typed `FormGroup`, async validators, functional interceptors (`HttpInterceptorFn`), retry strategies. | |
| 46 | +| **Stage 6** | **SSR, @defer & Enterprise Performance** | Event replay, incremental DOM hydration, `@defer` trigger conditions (`on viewport`, `on idle`), OnPush profiling. | |
| 47 | +| **Stage 7** | **Staff Architect Interview Handbook** | Zone.js patching vs Zoneless microtasks, Module Federation, 40+ staff-level interview Q&As, cheat sheet. | |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | + |
| 52 | +## 📋 Table of Contents |
22 | 53 |
|
23 | 54 | - [Introduction](#introduction) |
24 | 55 | - What is Angular? |
@@ -486,7 +517,53 @@ This repository contains a list of resources to learn Angular. It includes tutor |
486 | 517 | - Newsletters |
487 | 518 | - Podcasts |
488 | 519 |
|
489 | | -## Introduction |
| 520 | +## 1. Stage 1: Absolute Beginner Foundations & Standalone Architecture |
| 521 | + |
| 522 | +### 1.1 Architecture & Philosophy |
| 523 | +```mermaid |
| 524 | +flowchart TD |
| 525 | + Main["main.ts: bootstrapApplication(AppComponent, appConfig)"] --> AppConfig["app.config.ts: ApplicationConfig"] |
| 526 | + AppConfig --> Providers["provideRouter(), provideHttpClient(), provideClientHydration()"] |
| 527 | + Providers --> RootEnv["Root EnvironmentInjector"] |
| 528 | + RootEnv --> RootComp["AppComponent (Standalone Component)"] |
| 529 | + RootComp --> ChildComps["Child Standalone Components (Direct Imports)"] |
| 530 | +``` |
| 531 | + |
| 532 | +### Line-by-Line Code Breakdown: Standalone Bootstrapping (`src/main.ts` & `src/app/app.config.ts`) |
| 533 | + |
| 534 | +```typescript |
| 535 | +// app.config.ts |
| 536 | +import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; |
| 537 | +import { provideRouter, withComponentInputBinding } from '@angular/router'; |
| 538 | +import { provideHttpClient, withInterceptors } from '@angular/common/http'; |
| 539 | +import { routes } from './app.routes'; |
| 540 | +import { authInterceptor } from './core/auth.interceptor'; |
| 541 | + |
| 542 | +export const appConfig: ApplicationConfig = { |
| 543 | + providers: [ |
| 544 | + provideZoneChangeDetection({ eventCoalescing: true }), |
| 545 | + provideRouter(routes, withComponentInputBinding()), |
| 546 | + provideHttpClient(withInterceptors([authInterceptor])) |
| 547 | + ] |
| 548 | +}; |
| 549 | + |
| 550 | +// main.ts |
| 551 | +import { bootstrapApplication } from '@angular/platform-browser'; |
| 552 | +import { AppComponent } from './app/app'; |
| 553 | +import { appConfig } from './app/app.config'; |
| 554 | + |
| 555 | +bootstrapApplication(AppComponent, appConfig) |
| 556 | + .catch((err) => console.error('[Bootstrap Error]', err)); |
| 557 | +``` |
| 558 | + |
| 559 | +| Statement / API | Architectural Role | Pedagogical Runtime Mechanism | |
| 560 | +| :--- | :--- | :--- | |
| 561 | +| `ApplicationConfig` | **Configuration Interface** | Replaces historic `AppModule`. Holds the global array of environment providers passed during application bootstrap. | |
| 562 | +| `provideZoneChangeDetection({ eventCoalescing: true })` | **Event Coalescing** | Coalesces multiple microtasks and DOM events into a single change detection tick, significantly reducing redundant template re-evaluations. | |
| 563 | +| `withComponentInputBinding()` | **Router Feature** | Automatically maps route parameters (`:id`) and query parameters directly into component inputs (`input<string>()`) without subscribing to `ActivatedRoute`. | |
| 564 | +| `provideHttpClient(withInterceptors([...]))` | **HTTP Engine** | Configures tree-shakeable, functional HTTP interceptors instead of legacy multi-provider class tokens (`HTTP_INTERCEPTORS`). | |
| 565 | +| `bootstrapApplication(AppComponent, appConfig)` | **Platform Bootstrapper** | Mounts the root standalone component directly to the DOM host element without declaring an intermediate `NgModule`. | |
| 566 | + |
490 | 567 |
|
491 | 568 | ### What is Angular? |
492 | 569 |
|
@@ -1864,7 +1941,19 @@ import { AngularFireAnalyticsModule } from "@angular/fire/analytics"; |
1864 | 1941 | import { AngularFireAuthGuardModule } from "@angular/fire/auth-guard"; |
1865 | 1942 | ``` |
1866 | 1943 |
|
1867 | | -## Components |
| 1944 | +## 2. Stage 2: Standalone Components, Templates & Modern Control Flow |
| 1945 | + |
| 1946 | +```mermaid |
| 1947 | +flowchart TD |
| 1948 | + subgraph ControlFlow["Modern Angular Control Flow"] |
| 1949 | + IfBlock["@if (condition) { ... } @else { ... }"] |
| 1950 | + ForBlock["@for (item of items(); track item.id) { ... } @empty { ... }"] |
| 1951 | + SwitchBlock["@switch (status()) { @case ('active') { ... } }"] |
| 1952 | + DeferBlock["@defer (on viewport) { <heavy-chart /> } @placeholder { ... }"] |
| 1953 | + end |
| 1954 | +``` |
| 1955 | + |
| 1956 | +### 2.1 Standalone Components Deep Dive |
1868 | 1957 |
|
1869 | 1958 | ### Components |
1870 | 1959 |
|
@@ -5297,7 +5386,17 @@ Example: |
5297 | 5386 |
|
5298 | 5387 | [Back to top⤴️](#table-of-contents) |
5299 | 5388 |
|
5300 | | -## Signals |
| 5389 | +## 3. Stage 3: Modern Signals Reactivity & State Management |
| 5390 | + |
| 5391 | +```mermaid |
| 5392 | +flowchart LR |
| 5393 | + SourceSignal["signal(value) (State Node)"] --> ComputedSignal["computed(() => fn()) (Derived Node)"] |
| 5394 | + ComputedSignal --> EffectNode["effect(() => sideEffect()) (Consumer Node)"] |
| 5395 | + SourceSignal --> TemplateView["Template View Binding (Reactive UI)"] |
| 5396 | + Note over SourceSignal,EffectNode: Fine-grained tracking: only dependent nodes re-evaluate! |
| 5397 | +``` |
| 5398 | + |
| 5399 | +### 3.1 Signals Internals & Reactive Primitives |
5301 | 5400 |
|
5302 | 5401 | ### Signals Introduction |
5303 | 5402 |
|
@@ -7022,7 +7121,17 @@ export class LiveSearchComponent { |
7022 | 7121 | - **Signals**: Best for synchronous state management, template bindings, and local reactivity. |
7023 | 7122 | - **RxJS**: Best for asynchronous operations, event streams, timers, HTTP calls, and complex data flows. |
7024 | 7123 |
|
7025 | | -## Dependency Injection |
| 7124 | +## 4. Stage 4: Hierarchical Dependency Injection & Routing |
| 7125 | + |
| 7126 | +```mermaid |
| 7127 | +flowchart TD |
| 7128 | + PlatformInj["Platform Injector"] --> RootInj["Root EnvironmentInjector (provideIn: 'root')"] |
| 7129 | + RootInj --> RouteInj["Route / Environment Injector (Lazy Route Providers)"] |
| 7130 | + RouteInj --> ElementInj["Element Injector (Component @Component providers)"] |
| 7131 | + ElementInj --> DirectiveInj["Directive Injector"] |
| 7132 | +``` |
| 7133 | + |
| 7134 | +### 4.1 Dependency Injection Architecture |
7026 | 7135 |
|
7027 | 7136 | ### Dependency Injection |
7028 | 7137 |
|
@@ -8590,7 +8699,9 @@ export class AuthGuard implements CanLoad { |
8590 | 8699 |
|
8591 | 8700 | With `withComponentInputBinding()` enabled, Angular can automatically bind route parameters directly to component inputs (including Signal inputs). |
8592 | 8701 |
|
8593 | | -## Forms |
| 8702 | +## 5. Stage 5: Enterprise Reactive Forms & HTTP Client |
| 8703 | + |
| 8704 | +### 5.1 Reactive Forms Architecture |
8594 | 8705 |
|
8595 | 8706 | ### Forms Introduction |
8596 | 8707 |
|
@@ -12878,7 +12989,9 @@ Deferrable views can be used in component template to defer the loading of selec |
12878 | 12989 | } |
12879 | 12990 | ``` |
12880 | 12991 |
|
12881 | | -## Server-Side Rendering (SSR) |
| 12992 | +## 6. Stage 6: Server-Side Rendering (SSR), Deferrable Views & Performance |
| 12993 | + |
| 12994 | +### 6.1 Server-Side Rendering & Hydration |
12882 | 12995 |
|
12883 | 12996 | ### SSR Introduction |
12884 | 12997 |
|
@@ -17348,7 +17461,9 @@ Abstract data storage access routines from component consumers. |
17348 | 17461 |
|
17349 | 17462 | Delegate dependency resolution tasks dynamically using Angular's DI systems. |
17350 | 17463 |
|
17351 | | -## Interview Questions |
| 17464 | +## 7. Stage 7: Staff Angular Architect Interview Handbook & Cheatsheet |
| 17465 | + |
| 17466 | +### 7.1 40 Core Staff Architect Technical Interview Q&As |
17352 | 17467 |
|
17353 | 17468 | ### Angular Interview Questions |
17354 | 17469 |
|
|
0 commit comments