DEVELOPER SANDBOX Academy of Mastery
WelcomeBuild · Explore · Create SD
REFERENCE GUIDE

Angular Reference Guide

Angular setup, syntax, CLI, components, routing, forms, HTTP, testing, and macOS reference.

Quick jump:

Angular at a Glance

Angular is a TypeScript web application framework with components, templates, dependency injection, routing, forms, HTTP, reactive state, testing, and a first-party CLI.

This guide targets Angular 22.1-era standalone applications.

Current Major

Angular 22 is active. Current angular.dev pages are built with Angular 22.1.4.

Node Compatibility

Angular 22 supports Node ^22.22.3, ^24.15.0, or ^26.0.0. Node 24 LTS is a strong macOS baseline.

TypeScript

Angular 22 requires TypeScript >=6.0.0 <6.1.0.

Standalone-first

New components are standalone by default and import template dependencies directly.

Signals

signal() stores state; computed() derives values.

Control Flow

Use @if, @for, and @switch in modern templates.

Zoneless

Zoneless change detection is the default in Angular 21+.

Testing

New CLI projects use Vitest. Run with ng test.

macOS Setup & Installation

Use a Node version manager on a development Mac so projects can target supported Node versions cleanly.

Columns: Purpose / Commands / Notes.

Node + npm

Purpose: Angular CLI runs on Node and npm.

nvm install 24\nnvm use 24\nnode -v\nnpm -v

Notes: Node 24.15+ satisfies Angular 22. Use a project .nvmrc when a team standardizes on one Node major.

Angular CLI

Purpose: install the ng command.

npm install -g @angular/cli\nng version\nwhich ng

Notes: with nvm, routine sudo npm installs should not be necessary.

Editor Tooling

Purpose: completion, diagnostics, navigation, and refactoring.

  • VS Code or WebStorm
  • Angular Language Service
  • Browser DevTools

Use ng completion for CLI shell completion.

Create & Run a Project

ng new creates an Angular workspace and starter application.

Create Workspace

Create the workspace and initial application.

ng new my-app\ncd my-app
Routing + SCSS

Set common options explicitly.

ng new my-app --routing --style=scss
Development Server

Build, watch, serve, and reload during development.

ng serve\nng serve --open\nng serve -o
Default URL

Default CLI development address.

http://localhost:4200/
Different Port

Use another port when 4200 is occupied.

ng serve --port 4300

Angular CLI Commands

The CLI executable is ng. Common aliases include g, s, b, and t.

ng version
Help
New Workspace
Serve
Build
Generate Component
Generate Service
Generate Directive
Generate Pipe
Generate Guard
Generate Interceptor
Test
ng add
Update
Config
Completion

Workspace & File Map

Common files in a current standalone Angular application.

angular.json

Workspace build, serve, test, assets, styles, budgets, and target configuration.

package.json

npm dependencies and scripts. Angular packages use the @angular/* namespace.

tsconfig.json

TypeScript compiler configuration.

src/main.ts

Browser entry point. Standalone apps bootstrap with bootstrapApplication().

app.config.ts

Application-level providers such as router and HTTP configuration.

app.routes.ts

Route definitions when routing is enabled.

app.ts

Current CLI root component naming. Older workspaces often use app.component.ts.

dist/

Generated build output. Do not hand-edit it.

Components & Directives

Components define UI with a template. Directives package reusable behavior on existing hosts.

Minimal Component
External Template / Style
Standalone Imports
Use a Child Component
Attribute Directive

Template Syntax

Angular templates are HTML plus expression, binding, control-flow, variable, and pipe syntax.

Interpolation
Property Binding
Event Binding
Class / Style Binding
@if
@for
@switch
Pipes

Signals & Reactive State

Signals are synchronous reactive primitives. Read a signal by calling it as a function.

signal()
set()
update()
computed()
effect()

Inputs & Outputs

Inputs pass data into components. Outputs emit custom events to consumers.

input()
input.required()
output()
Listen to Output
Older Compatibility APIs

Services & Dependency Injection

Dependency injection lets classes request collaborators rather than constructing them directly.

Root Service
inject()
Component Provider
InjectionToken

Router Quick Reference

Routes map URLs to components. Angular uses first-match wins.

Define Routes
provideRouter()
RouterOutlet
Lazy Route
Programmatic Navigation
Guard

Forms

Reactive forms remain a strong stable default. Template-driven and Signal Forms are also available.

Reactive FormControl
FormGroup
Validators
Template-driven / ngModel
Signal Forms

HTTP & API Calls

HttpClient is injectable by default in Angular 21+. Current Angular uses Fetch by default unless configured for XHR.

Inject HttpClient
GET
Query Parameters
POST
PUT / PATCH / DELETE
Configure HttpClient
Functional Interceptor

RxJS Essentials

Signals fit synchronous state; RxJS remains useful for asynchronous streams and HTTP pipelines.

Observable
AsyncPipe
map()
switchMap()
toSignal()

Lifecycle & Cleanup

Use lifecycle hooks when timing matters and DestroyRef for explicit cleanup close to setup code.

ngOnInit
ngOnChanges
afterNextRender
DestroyRef

Testing

New CLI projects use Vitest by default. TestBed remains the Angular-aware testing utility.

Run Tests
Simple Unit Test
TestBed Component
Rendered DOM
HTTP Testing

Build, Update & Deploy

Build optimized output for deployment; do not deploy the development server.

Production Build
Inspect Output
Check Updates
Update Framework + CLI
ng deploy

Modern Implementation Practices

Current defaults for new Angular work plus compatibility guidance for existing projects.

Standalone-first
Prefer inject()
Signals for local state
Track @for items
Keep components focused
Lazy-load deliberately
Keep types strong
Respect security boundaries
Stay current

Troubleshooting Fast Map

Check runtime versions, imports, route order, and workspace context before reinstalling everything.

ng not found

Check which node, which npm, and npm prefix -g. Install the CLI under the active nvm Node version.

Unsupported Node

Run node -v and ng version. Angular 22 needs Node 22.22.3+, 24.15+, or 26.x.

Port 4200 Used

Use ng serve --port 4300. On macOS inspect the owner with lsof -i :4200.

Unknown Element / Pipe

For standalone components, confirm the dependency appears in imports.

Cannot Bind Property

The component or directive input may not be imported, or the binding name may be wrong.

NullInjectorError

A requested dependency has no provider in the active injector hierarchy.

Route Never Reached

Router matching is first-match wins. Put specific routes first and ** last.

CORS Error

CORS is a browser and server policy. Configure the backend or a development proxy.

View Not Updating

In zoneless Angular, state changes need an Angular-recognized notification path such as signals, input changes, or template events.

After an Update

Review migration output, reinstall from the lockfile, run ng test, then run ng build.

Official Documentation & Downloads

Use current official documentation whenever setup or API behavior is version-sensitive.

Angular Home

Current documentation, tutorials, guides, and APIs.

Installation

Node prerequisites, CLI installation, and first project.

Local Setup

Detailed CLI environment and workspace setup.

CLI Reference

Complete ng command reference.

Version Compatibility

Angular, Node.js, TypeScript, and RxJS compatibility.

Releases

Supported versions and release schedule.

Update Guide

Interactive version migration guidance.

Components

Component anatomy and authoring.

Inputs

input(), required inputs, transforms, and compatibility APIs.

Outputs

output(), emit, event binding, and compatibility APIs.

Templates

Template syntax and control flow.

Signals

signal(), computed(), effects, and reactive contexts.

Dependency Injection

Providers, injectors, services, and inject().

Routing

Routes, outlets, links, guards, and lazy loading.

Forms

Reactive and template-driven forms.

Signal Forms

Signal-based forms and current stability guidance.

HTTP

HttpClient, requests, interceptors, configuration, and testing.

Testing

Current Vitest-based default testing.

Zoneless

Default zoneless change detection model.

Style Guide

Angular team naming, structure, and DI recommendations.

Security

Security model, sanitization, XSS protections, and security guidance.

Angular Language Service

Editor completion and template diagnostics.