Angular Tutorial
Learn modern Angular from your first component to signals, templates, dependency injection, routing, forms, HTTP, RxJS, testing, performance and real projects. 74 lessons with examples, quizzes and projects.
Start learning →
of lessons completed
Getting Started
- What Is Angular? Learn what Angular is, how a batteries-included framework differs from a library like React, how releases work, and how this tutorial mixes real code with runnable demos.
- Modern Angular vs AngularJS AngularJS 1.x is retired. See how modern Angular differs (TypeScript, components, signals, no $scope or digest cycle) and which old tutorials advice to ignore.
- Setup and the Angular CLI Install Node and the Angular CLI, create a project with ng new, run it with ng serve and learn the project layout, angular.json, main.ts and app.config.ts.
- Your First Component Write your first Angular component. Learn the @Component decorator, selector, template, styles and the imports array, and how a decorator works as metadata.
- How Angular Works See what happens between your code and the screen - the AOT compiler, template instructions, bootstrapping, the component tree, zone-less change detection and the esbuild build.
- NgModules and Legacy Angular Code Read and migrate older Angular code. Learn what an NgModule is, how declarations, imports, exports and providers work, feature and shared modules, and how to move to standalone.
Templates and Data Binding
- Interpolation and Template Expressions Learn Angular interpolation with double curly braces, which expressions templates allow, safe navigation, nullish coalescing, pipes and template reference variables.
- Property, Attribute, Class and Style Binding Learn Angular's square-bracket bindings - [property], [attr.x], [class.x] and [style.x] - how properties differ from attributes, and how innerHTML is sanitized.
- Event Binding and $event Learn Angular event binding - (click), the $event object, key filters like (keydown.enter), handler methods, preventDefault and how outputs use the same syntax.
- Two-Way Binding and model() Understand Angular two-way binding - the banana-in-a-box syntax, [(ngModel)] with FormsModule, model() signal inputs, and how it all desugars to one input plus one output.
- Control Flow: @if, @for and @switch Learn Angular's built-in control flow blocks - @if/@else, @for with track and @empty, @switch, @let - why track matters, and how to migrate from *ngIf and *ngFor.
- Pipes Learn Angular pipes - date, currency, number, percent, json, async, slice, keyvalue, chaining, pure versus impure pipes and how to write a custom PipeTransform.
- Animations in Angular Animate elements as they enter, leave and change state in Angular with animate.enter and animate.leave, the classic trigger API, route transitions and reduced-motion support.
Components in Depth
- Inputs and Outputs Learn how Angular components talk to each other - input(), input.required, transform, alias, output(), the legacy @Input and EventEmitter, and one-way data flow.
- Content Projection Learn Angular content projection - ng-content slots, select, ngProjectAs, ng-container, and ng-template with ngTemplateOutlet - with runnable stand-ins.
- Lifecycle Hooks and afterNextRender Learn the Angular component lifecycle - ngOnInit, ngOnChanges, ngOnDestroy, afterNextRender, afterEveryRender and DestroyRef - with a runnable simulator.
- Template Refs, View Queries and Host Bindings Learn Angular template reference variables, viewChild, viewChildren, contentChild, ElementRef, host metadata and hostDirectives with runnable stand-ins.
- Styling Components and View Encapsulation Understand Angular component styles, styleUrl, Emulated, ShadowDom and None encapsulation, :host, ::ng-deep and CSS variable theming with live demos.
- Attribute and Structural Directives Build Angular attribute directives with host listeners and inputs, compose them with hostDirectives, and learn how structural directives and ng-template work.
- Using Tailwind, Bootstrap and Sass in Angular Add Sass, Tailwind CSS and Bootstrap (ng-bootstrap) to an Angular project. Learn where global styles go, how encapsulation interacts with frameworks, and when to choose each, with runnable stand-ins.
Signals and Reactivity
- Signals: signal, computed and effect Learn Angular signals from the ground up - writable signals, lazy memoized computed values, effects, untracked and equality - with a runnable mini implementation.
- Signals in Components Learn how to use Angular signals inside components - private state, read-only exposure, computed values, input(), model(), viewChild(), toSignal() and the mistakes to avoid.
- linkedSignal, resource and httpResource Learn linkedSignal for state that resets when its source changes, and resource() and httpResource() for loading async data with status, value, error and cancellation.
- Change Detection, OnPush and Zoneless Understand how Angular decides when to update the page - Zone.js, the Default and OnPush strategies, markForCheck, signals and zoneless change detection - with runnable stand-ins.
Dependency Injection and Services
- Services and Dependency Injection Learn Angular services and dependency injection - @Injectable, providedIn root, inject() versus constructor injection, singletons, the injector tree and a runnable mini DI container.
- Providers, InjectionToken and Scopes Learn Angular providers (useClass, useValue, useFactory, useExisting), InjectionToken, multi providers, component and route scopes and environment injectors, with a runnable mini DI.
- State Management with Signals and Services Manage shared state in Angular with signal-based services - immutable updates, derived state, scoping, a look at NgRx SignalStore and when a bigger tool pays off.
Routing
- Routing Basics Set up the Angular router with provideRouter, define Routes, render pages in router-outlet, link with routerLink, and handle redirects and wildcard routes.
- Route Parameters, Query Params and Navigation Read path and query parameters with input binding or ActivatedRoute, navigate from code with Router.navigate and relative links, and set page titles per route.
- Child Routes and Lazy Loading Build nested layouts with child routes, split your app into lazy-loaded chunks with loadComponent and loadChildren, and choose a preloading strategy.
- Guards, Resolvers and Router Events Protect routes with functional guards (canActivate, canMatch, canDeactivate), preload page data with resolvers, redirect with UrlTree and react to router events.
- Authentication with JWT: Tokens, Refresh and Role Guards Learn how JWT login works in Angular - token anatomy, where to store tokens, a refresh interceptor that avoids request storms, and expiry-aware role guards, with runnable stand-ins.
Forms
- Template-Driven Forms Build Angular forms in the template with FormsModule, ngModel and ngForm, use validation attributes and control states, and decide when this approach is the right one.
- Reactive Forms Build typed Angular reactive forms with FormControl, FormGroup, FormArray and FormBuilder, read value and status, react to valueChanges and avoid the null-on-reset trap.
- Validation and Custom Validators Learn Angular form validation: built-in validators, custom sync validators, cross-field group validators, async validators, error messages and updateOn, with runnable stand-ins.
- Signal Forms Meet Angular's experimental signal forms: a model signal as the single source of truth, field state as signals, schema validation, and how it compares with reactive forms.
- Dynamic Forms and Custom Form Controls Build Angular forms that change at runtime with FormArray rows and config-driven fields, multi-step wizards, file uploads and ControlValueAccessor widgets, with runnable stand-ins.
HTTP and RxJS
- RxJS Essentials: Observables Understand RxJS observables for Angular: lazy streams versus promises, subscribe and unsubscribe, cold versus hot, Subject and BehaviorSubject, with a runnable tiny Observable.
- RxJS Operators You Need Learn the RxJS operators Angular developers use daily: map, filter, tap, switchMap, mergeMap, concatMap, debounceTime, combineLatest, catchError, with runnable stand-ins.
- HttpClient: Requests and Responses Learn Angular HttpClient: provideHttpClient and withFetch, typed GET, POST, PUT and DELETE, params and headers, HttpErrorResponse handling, with a runnable fetch-based stand-in.
- HTTP Interceptors Learn how Angular's functional HTTP interceptors add auth headers, log requests, retry failures and map errors, and how their order works.
- Error Handling: ErrorHandler and HTTP Errors Handle errors in Angular properly with a custom ErrorHandler, an HTTP error interceptor, retries for safe requests, a logging service and a friendly error message for users.
- Signals and RxJS Interop Bridge signals and RxJS in Angular with toSignal, toObservable, takeUntilDestroyed and outputFromObservable, and learn when to use which.
Quality and Performance
- Testing Components and Services Test Angular components, signals and services with TestBed, ComponentFixture, HttpTestingController and harnesses, and practice with a mini test runner.
- SSR, Hydration and Prerendering Understand Angular server-side rendering, static prerendering, hydration, event replay and transfer state, and how to write browser-only code safely.
- Deferrable Views and Image Optimization Load Angular components lazily with @defer triggers, placeholders, loading and error blocks, prefetching, and serve faster images with NgOptimizedImage.
- Performance Tuning Speed up Angular apps by measuring first, then shrinking bundles, tracking lists, using signals and OnPush, virtual scrolling and the Angular DevTools profiler.
- Security and Accessibility Keep Angular apps safe and usable - template sanitization, DomSanitizer pitfalls, XSRF protection, CSP, token storage, ARIA bindings, focus management and the CDK a11y tools.
- Internationalization and Localization Translate an Angular app with i18n attributes, $localize, ng extract-i18n, ICU plural and select messages and locale-aware pipes, and learn when runtime translation libraries fit better.
- End-to-End Testing with Playwright Test a whole Angular app in a real browser with Playwright. Learn locators, auto-waiting, running against ng serve, page objects, mocking APIs and CI, with runnable logic stand-ins.
- PWAs and Service Workers Turn an Angular app into a Progressive Web App with ng add @angular/pwa. Learn ngsw-config caching groups, offline behavior and SwUpdate, with runnable cache-strategy stand-ins.
- Web Workers in Angular Keep your Angular UI smooth by moving heavy computation into a Web Worker. Learn ng generate web-worker, message passing, signals integration and when not to use one, with runnable stand-ins.
Tooling and Ecosystem
- Angular Material and the CDK Learn what Angular Material and the Component Dev Kit offer, how to add components and theme them, and how CDK drag-drop and virtual scroll work, with runnable logic stand-ins.
- Project Structure and Best Practices Organize an Angular app by feature, follow a consistent naming style, split smart and presentational components, turn on strict mode and lint rules, and keep upgrades painless.
- Building and Deploying Build an Angular app for production with ng build, understand the output, budgets and environments, host it as static files with SPA fallback and caching, and automate it with Docker and CI.
- Angular Elements and Web Components Package an Angular component as a standard custom element with @angular/elements, use it in plain HTML, and learn how inputs, outputs and the limits map to the Web Components standard.
- What Changed in Each Angular Version A readable timeline of Angular from the 2016 rewrite to Ivy, standalone components, signals, new control flow and zoneless apps, plus how to upgrade safely with ng update.
- Building and Publishing an Angular Library Create a reusable Angular library with the CLI, design its public API, set peer dependencies, build it with ng-packagr and publish it to npm. Includes runnable stand-ins for the checks.
- Using Third-Party JavaScript Libraries (Chart.js, jQuery) in Angular Wrap non-Angular libraries such as Chart.js or jQuery in a component with viewChild, afterNextRender, effect and runOutsideAngular, add types, and clean up, with runnable stand-ins.
Projects
- Project: Todo App with Signals Build a todo app in Angular with a signal-based store, computed filters, small presentational components and persistence, plus runnable stand-ins for the logic and the UI.
- Project: Weather Dashboard with HttpClient Build an Angular weather dashboard in four steps - a typed service, loading and error states with resource(), and a debounced city search. Real code plus runnable fake-API stand-ins.
- Project: Shopping Cart and Checkout Build an Angular shopping cart in four steps - a signal-based cart service, computed totals, a route guard for checkout and a reactive checkout form. Includes runnable cart logic.
- Project: Blog with Routing and Lazy Routes Build an Angular blog with routes, a resolver that loads each post, a lazy blog area, pagination through query params and per-page titles and meta tags. Includes a runnable mini router.
- Project: Admin Dashboard with Auth Build an Angular admin dashboard with a login flow, an auth interceptor, role-based route guards and a sortable, filterable users table driven by signals. Runnable stand-ins included.
- Project: Quiz App with Reactive Forms Build a quiz app in Angular with questions loaded from data, a reactive form for the answers, a scored result and a small animation, with runnable logic and UI stand-ins.
- Project: Expense Tracker with Services and localStorage Build an expense tracker in Angular with a signal-based service, money stored in cents, category filters, totals and safe localStorage persistence, with runnable stand-ins.
- Project: Snake Game on a Canvas Build a Snake game in Angular with a pure game-logic function, a canvas renderer, keyboard input and a game loop that runs outside Angular's change detection, with runnable stand-ins.
- Project: Event Calendar Build a month-view event calendar in Angular with a pure month-grid function, small components using input and output, the date pipe and safe persistence, with runnable stand-ins.
- Project: Movie Search App Build a movie search app in Angular with HttpClient, a debounced search box using RxJS, a detail route and honest loading and error states, with a fake API and runnable stand-ins.
- Project: Realtime Chat with WebSockets Build a realtime chat in Angular with RxJS webSocket, a signal-based message list, validated incoming messages and automatic reconnect with backoff, using a fake socket in the runnable stand-ins.
Practice and Review
- Practice Exercises with Solutions Twenty graded Angular exercises on signals, templates, dependency injection, routing, forms and RxJS, each with a full solution and runnable stand-ins for the logic.
- Common Mistakes and Pitfalls The Angular mistakes beginners and teams keep making - mutated signals, missing track, leaked subscriptions, ExpressionChanged errors, effect misuse and RxJS overuse - with runnable demos.
- Angular Interview Questions 40 Angular interview questions with concise answers, from components and signals to DI, change detection, RxJS, routing, forms and performance, with two runnable examples.
- Angular Cheat Sheet A one-page Angular cheat sheet for modern Angular - CLI commands, template syntax, control flow, signals, DI, routing, forms, HttpClient, RxJS operators and testing snippets.