Frameworks
Build Angular apps from components and templates to signals, routing, forms, SSR, testing and i18n.
A complete path through modern Angular: standalone components, templates and the new control flow, dependency injection, routing, forms, HttpClient with RxJS, signals and zoneless change detection, then the CLI, rendering on the server, security, accessibility, performance, testing, i18n and animation. Aimed at developers who know TypeScript and want to ship production Angular apps. Each subject links the official documentation.
The subjects follow the roadmap.sh Angular roadmap.
Angular is a batteries-included TypeScript framework from Google: components, routing, forms, HTTP, testing and a CLI all ship together and are versioned in lockstep. That makes it opinionated but predictable, which is why large teams and enterprises favour it. A new major version arrives roughly every six months, with ng update to migrate.
An app is a tree of components that render templates, backed by injectable services for logic and data. A compiler turns templates into efficient instructions at build time, and change detection (zone.js or signals) keeps the DOM in sync with state.
Install the CLI with npm install -g @angular/cli, then ng new my-app asks about stylesheet format and server-side rendering. ng serve starts a dev server with hot reload; the generated angular.json holds build and test configuration.
AngularJS (1.x, 2010) was rewritten from scratch as Angular 2 in 2016, with TypeScript and components. Since then: the Ivy renderer, standalone components replacing NgModules as the default, built-in control flow, and signals as the reactivity model.
The building block of every Angular UI: a TypeScript class decorated with @Component, a template and optional styles. The decorator's metadata tells the compiler how to find the component in markup, what it may use in its template and how it should be rendered and checked for changes.
A class holding state and behaviour, the @Component decorator with its metadata, and a template that renders the class's properties. The class instance lives as long as the element is on the page.
Run ng generate component user-card (or ng g c) to scaffold the class, template, styles and spec file. Then add it to a parent's imports and use its selector in the parent template.
The options object passed to @Component: selector, template or templateUrl, styles or styleUrl, imports, providers, changeDetection, encapsulation, host and more. It is read at compile time, so values must be static.
The component's HTML, inline with template or in a separate file via templateUrl. Templates are compiled ahead of time, so typos in bindings fail the build instead of failing in the browser.
A CSS selector that tells Angular where to create the component. Usually an element selector with a project prefix (app-user-card), but attribute selectors such as button[appPrimary] let a component extend a native element.
Components, directives and pipes that declare their own dependencies in imports instead of belonging to an NgModule. Standalone is the default in current versions, and apps start with bootstrapApplication.
Component styles via styles or styleUrl are scoped to that component by default. Use :host to style the host element and avoid ::ng-deep, which is deprecated and leaks styles globally.
The providers array creates a service instance for this component and all its descendants, separate from any root singleton. Useful for per-widget state, such as a store scoped to one form.
Everything a standalone component's template uses (other components, directives, pipes, or NgModules that export them) must appear in its imports array. The compiler reports unknown elements and unused imports.
viewProviders work like providers but are visible only to the component's own view, not to content projected into it through <ng-content>. Use them to keep an internal service from leaking into consumer-supplied children.
ViewEncapsulation.Emulated (default) rewrites selectors with generated attributes; ShadowDom uses the browser's real shadow root; None makes the styles global. Pick None only for deliberate global styling.
ChangeDetectionStrategy.OnPush checks a component only when an input reference changes, a template event fires, an async pipe emits or a signal it reads updates. Combined with immutable data and signals it cuts most wasted checks.
Components talk to each other through inputs going down, outputs going up, queries that reach into child views, and shared services for anything further apart. Knowing the component lifecycle tells you when each of those values is available.
A parent passes data with [user]="selected" and listens with (saved)="onSave($event)". For siblings or distant components, share a service holding a signal instead of chaining inputs and outputs through every level.
Query an element, directive or child component from your own template. The signal form viewChild(MyChart) returns a signal; the decorator @ViewChild is resolved by ngAfterViewInit. viewChildren returns all matches.
Query what a consumer projected into your component through <ng-content>, such as a tab component finding its tab panels. Use contentChild or contentChildren; results are ready after content initialisation.
Hooks such as ngOnInit, ngOnChanges, ngAfterViewInit and ngOnDestroy mark creation, input changes, rendering and teardown. afterNextRender is the safe place for direct DOM work, and DestroyRef registers cleanup without implementing a hook.
Create components at runtime when the type is not known in the template: ViewContainerRef.createComponent(Type) or the NgComponentOutlet directive. Common for dialogs, dashboards and plugin-style UIs; pass inputs with setInput.
NgModules group declarations and providers into units, and were required before standalone components. New code rarely needs them, but most existing Angular codebases and many libraries still use them, so you must be able to read and migrate them.
A typical layout has a root AppModule, a shared module for reusable components and pipes, and feature modules per business area. Services meant as singletons belong in providedIn: 'root', not in a shared module.
A class decorated with @NgModule listing declarations, imports, exports and providers. Only exported declarations are usable by modules that import it.
Modules that own one area of the app (orders, admin), with their own routes and components. They keep boundaries clear and are the natural unit for lazy loading.
Load a module only when its route is visited with loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule). The bundler splits it into its own chunk, shrinking the initial download.
A module can use only what it imports, and what those modules export. Watch for duplicated providers when a module with providers is imported in several lazy modules; the forRoot()/forChild() pattern exists to avoid that.
Binding connects component state to the DOM and DOM events back to the component. Angular's template syntax makes the direction explicit: square brackets push values in, parentheses listen for events, and the "banana in a box" [( )] does both.
The umbrella term for keeping view and state in sync: one-way from class to view (interpolation, property, attribute, class and style bindings), one-way from view to class (events), and two-way.
[disabled]="isSaving" sets a DOM property or a component input to the result of an expression. It binds to properties, not HTML attributes, which is why [value] and value can behave differently.
For attributes that have no matching DOM property, such as ARIA attributes or colspan, use [attr.aria-label]="label". Binding null removes the attribute.
(click)="save()" runs a statement when the event fires; $event holds the event object or an output's payload. Key filters like (keyup.enter) save boilerplate.
[(value)]="name" combines a property binding with a matching valueChange event. Write your own two-way inputs with model(), and use [(ngModel)] from FormsModule on form controls.
The classic decorators for a component's public API: @Input() receives values, @Output() with an EventEmitter raises events. Current code prefers the input() and output() functions, which return a signal and a typed emitter.
Angular templates are HTML extended with bindings, control flow blocks, pipes and local variables. The compiler type-checks them against the component class, so turning on strict template checking catches null errors and wrong input types at build time.
{{ user.name }} renders an expression as text, escaped automatically. Keep expressions cheap and free of side effects; anything complex belongs in a computed signal or a pipe.
The code on the right of an event binding, like (click)="count.set(count() + 1)". Statements may assign and call methods but cannot use new, increment operators or arbitrary globals.
Built-in blocks (@if, @for, @switch) replace the older *ngIf, *ngFor and ngSwitch directives. They need no imports, type-narrow better and run faster; ng generate @angular/core:control-flow migrates existing templates.
#nameInput gives a template-local name to an element, component or directive (#form="ngForm"). Use it to read a value in an event handler or pass a reference to a method without a query.
The block syntax that starts with @ covers conditionals, loops, switches, local variables and deferred loading directly in the template. It is compiled away, adds no runtime directives and is the recommended style for all new code.
Renders a block only when its condition is truthy. @if (user(); as u) stores the result in a local variable, avoiding repeated calls and narrowing the type.
The fallback block after an @if, rendered when no condition matched. Handy for empty states and loading placeholders.
Chains further conditions after an @if; the first truthy branch wins. Once the chain grows past two or three branches on one value, @switch usually reads better.
Loops over an iterable and requires a track expression, such as track item.id, so Angular can reuse DOM nodes. Exposes $index, $first, $last, $even, $odd and $count, and an @empty block for empty lists.
Picks one block by comparing a value with strict equality against each case. Unlike JavaScript there is no fall-through, so no break is needed.
One branch inside @switch, rendered when its value equals the switch expression with ===. Each case holds its own block of markup.
The branch inside @switch rendered when no @case matched. Leave it out and nothing renders for unknown values.
Declares a read-only local variable in the template, for example @let total = cart().total;. It cuts repeated expressions and pairs well with the async pipe to unwrap an observable once.
Splits a part of the template and its dependencies into a lazily loaded chunk. Triggers such as on viewport, on interaction, on idle or when cond decide when it loads, with @placeholder, @loading and @error blocks around it.
Pipes transform a value for display right in the template, as in {{ price | currency:'EUR' }}. They are pure functions by default, so Angular can skip re-running them when the input is unchanged, which makes them cheaper than calling a method in the template.
From @angular/common: date, currency, number, percent, json, keyvalue, slice, uppercase, and async, which subscribes to an observable or promise and unsubscribes on destroy. Import each one into the component that uses it.
The pipe operator binds tighter than the ternary operator, so a ? b : c | upper only transforms c. Wrap the expression in parentheses when you mean the whole result.
A pure pipe re-runs only when its input changes by reference, so mutating an array in place will not update the output. An impure pipe (pure: false) runs on every check; use it sparingly.
A class with @Pipe({ name: 'initials' }) implementing transform(value, ...args). Generate one with ng g pipe, keep it pure and free of side effects, and test it like a plain function.
Directives add behaviour to existing elements without a template of their own. Components are directives with a view; the rest either change an element's appearance and behaviour or change the DOM structure around a template.
Directives applied with * that create or remove views from an <ng-template>, using TemplateRef and ViewContainerRef. Built-in control flow replaced most uses, but custom ones still help for things like permission checks.
Change how an element looks or behaves: NgClass, NgStyle, NgModel, or your own. Plain [class.active] and [style.width.px] bindings now cover most styling needs without importing a directive.
A class with @Directive({ selector: '[appAutofocus]' }) that injects ElementRef and reacts with host bindings and listeners. The directive composition API (hostDirectives) lets components reuse them.
The Angular Router maps URLs to components, supports nested and lazy-loaded routes, and guards navigation. Register it with provideRouter(routes). For accessibility, move focus to the new page's main heading after each navigation, because screen readers do not notice a client-side route change on their own.
A Routes array of objects with path, component, children, redirectTo and pathMatch, ending with a ** wildcard for 404s. withComponentInputBinding() passes route params straight into component inputs.
Use loadComponent or loadChildren with a dynamic import() to split routes into separate chunks. Add a preloading strategy such as withPreloading(PreloadAllModules) to fetch them in the background.
<router-outlet /> marks where the matched component renders. Nested routes need an outlet in the parent component; named outlets let secondary content such as a side panel have its own URL segment.
routerLink="/users" or [routerLink]="['/users', id]" navigates without a full reload; routerLinkActive adds a class to the active link. In code, call router.navigate() or navigateByUrl().
The router emits NavigationStart, NavigationEnd, NavigationCancel, NavigationError and more on router.events. Use them for loading bars, analytics and scroll or focus handling.
Functional guards decide whether navigation may proceed: CanActivateFn, CanMatchFn, CanDeactivateFn for unsaved changes, and ResolveFn to load data first. They can inject() services and return a UrlTree to redirect.
Services hold logic and state that does not belong to one component: API calls, caching, authentication, shared stores. Mark them @Injectable({ providedIn: 'root' }) for an app-wide, tree-shakable singleton and inject them where needed.
Angular builds a tree of injectors that hand out instances on request. Use inject(Service) in fields or constructors, configure alternatives with useClass, useValue, useFactory and InjectionToken, and lean on DI to swap real services for fakes in tests.
Angular ships two form APIs: template-driven forms built from directives in the markup, and reactive forms built as a model in the class. Reactive forms scale better and are easier to test; newer versions also add an experimental signal-based forms API.
Build FormGroup, FormControl and FormArray in the class (often with FormBuilder) and bind them with [formGroup] and formControlName. State changes flow through valueChanges observables.
Reactive form controls infer their value types, so form.value.email is string | null | undefined. Use nonNullable: true or NonNullableFormBuilder to reset to the initial value instead of null, and getRawValue() to include disabled controls.
Import FormsModule and bind inputs with [(ngModel)] and a name; validation comes from attributes like required and minlength. Fine for small forms, harder to test and compose as they grow.
Generate a form from metadata (a questionnaire definition or a JSON schema) by building a FormGroup in code and rendering controls with @for and @switch. Useful when fields come from the server.
A ValidatorFn returns null when valid or an error object such as { weakPassword: true }. Apply cross-field validators to the group, and use AsyncValidatorFn for server checks with updateOn: 'blur' to limit requests.
Implement ControlValueAccessor (writeValue, registerOnChange, registerOnTouched, setDisabledState) and provide NG_VALUE_ACCESSOR so your own component, like a star rating, works with formControlName and ngModel.
HttpClient wraps requests in typed observables with JSON parsing, interceptors, progress events and test utilities built in. Requests are cold: nothing is sent until something subscribes.
Add provideHttpClient() to the application providers, with features such as withInterceptors([...]) and withFetch(), which uses the Fetch API and is recommended for server-side rendering.
http.get<User[]>('/api/users', { params }) returns an observable of the typed body. Handle errors with catchError, cancel by unsubscribing, and consider httpResource to expose a request as a signal.
An HttpInterceptorFn sees every request and response: attach auth headers, retry, log, or map errors. Requests are immutable, so use req.clone({ setHeaders }), and remember order matters.
RxJS models values over time as observables you compose with operators. Angular uses it for HTTP, router events and reactive forms, so you need the core ideas even as signals take over component state.
A producer pushes values to subscribed observers, which receive next, error and complete notifications. Unlike an event emitter, a cold observable starts its work separately for each subscriber.
Creation, subscription, execution and teardown: an observable runs until it completes, errors or is unsubscribed. Forgetting to unsubscribe from long-lived streams leaks memory; takeUntilDestroyed() or the async pipe handles it for you.
A promise is eager, resolves once and cannot be cancelled. An observable is lazy, can emit many values and is cancelled by unsubscribing. Convert with firstValueFrom or lastValueFrom when you only need one value.
Pure functions passed to .pipe() that return a new observable. Learn the flattening operators carefully: switchMap cancels the previous inner stream, mergeMap runs in parallel, concatMap queues and exhaustMap ignores new values while busy.
Operators that let only some values through: filter, take, first, skip, distinctUntilChanged and takeUntil. They are how you stop a stream after a condition or ignore duplicates.
debounceTime waits for a pause (search-as-you-type), throttleTime lets one value through per window, and auditTime emits the latest value at the end of each window.
Operators that reshape values: map, scan for running state, buffer and bufferTime for batching, and the higher-order switchMap family that maps each value to a new observable.
combineLatest emits whenever any source emits once all have a value; forkJoin waits for all to complete (parallel HTTP calls); merge interleaves; withLatestFrom samples another stream.
Signals are Angular's fine-grained reactive primitive: signal() holds a value, computed() derives one lazily and effect() runs side effects when dependencies change. Templates that read signals let Angular update exactly the views that depend on them, which is the basis for zoneless apps.
toSignal(obs$) turns an observable into a signal (handle the initial undefined or pass initialValue), and toObservable(sig) goes the other way. Use observables for event streams and timing, signals for state the template reads.
name = input<string>() or input.required<User>() exposes an input as a read-only signal, so you can derive from it with computed instead of ngOnChanges. Options include alias and a transform such as booleanAttribute.
viewChild, viewChildren, contentChild and contentChildren return signals that update as the DOM changes, with .required variants. No more waiting for ngAfterViewInit to read them.
value = model(0) is a writable input: the component can set it and the parent sees the change through [(value)]. It is the signal-based way to build two-way bindable components.
Most apps manage fine with services that expose signals. Reach for a library when many features share complex state, you need time-travel debugging or a strict unidirectional flow, and accept the extra boilerplate that comes with it.
A store library built around classes and decorators (@State, @Action, @Selector), with less ceremony than Redux-style setups. Good for teams that want a central store without writing reducers by hand.
The most widely used Angular state library: Redux-style Store with actions, reducers, selectors and effects, plus @ngrx/signals (SignalStore) for lighter signal-based stores. Redux DevTools integration gives action logs and time travel.
Historically Angular used zone.js to patch browser async APIs (timers, events, promises) and run change detection after each task. It is convenient but coarse and adds bundle weight. NgZone.runOutsideAngular lets hot code such as animations or polling skip it.
Without zone.js, change detection is triggered by signal updates, template events, markForCheck and the async pipe. Enable it with provideZonelessChangeDetection(), remove zone.js from polyfills, and use OnPush-friendly patterns throughout.
Beyond the CLI, Angular offers a browser extension for inspecting a running app and a language service that brings template awareness to your editor. Both pay off as soon as you start debugging change detection or DI.
A Chrome and Firefox extension that shows the component tree with inputs and state, the injector hierarchy, router tree and signal graph, and a profiler that records change detection cycles so you can spot slow components.
Powers completions, go-to-definition, hover info and inline errors in templates. Install the official Angular extension in VS Code; other editors integrate the same server.
The ng command creates, generates, serves, builds, tests and updates projects. It drives an esbuild-based build system configured in angular.json, and ng update applies migrations that rewrite your code between major versions.
You need a supported Node.js release (see the compatibility table) and the global @angular/cli package; then ng new scaffolds a workspace. Check the version compatibility table before upgrading Node or TypeScript.
Named configurations in angular.json (development, production, your own staging) control optimisation and source maps, and fileReplacements swaps an environment.ts per build. Never put secrets there: everything ships to the browser.
Builders are the functions behind ng build, ng serve and ng test, chosen per target in angular.json, such as @angular/build:application. You can write your own or install community ones.
Ahead-of-time compilation turns templates into JavaScript during the build, so the browser downloads no compiler and template errors fail the build. It is the default for both development and production.
Code generators and transformers behind ng generate, ng add and ng update. Libraries ship schematics to install themselves, and you can author your own to enforce team conventions.
ng e2e runs browser tests against the built app; the first run offers to add a package for a runner such as Playwright or Cypress. Test real user journeys and keep the suite small and stable.
ng build writes static files to dist/<project>/browser; serve them with a fallback to index.html so deep links work. ng deploy runs a deploy builder for hosts like Firebase, and SSR builds also produce a Node server.
Libraries share code across apps or with the community. Angular has its own packaging conventions (the Angular Package Format), so building and consuming libraries works a bit differently from plain npm packages.
Install with ng add when the library provides a schematic, so it configures itself, or with npm otherwise. Check that its peer dependencies match your Angular version before upgrading.
ng generate library my-lib adds a library project built with ng-packagr. Define the public API in public-api.ts, list Angular as a peer dependency and publish the dist output, not the source.
Server-side rendering produces HTML on the server for each request, improving first paint and SEO, then the client takes over. Add it with ng new --ssr or ng add @angular/ssr. Guard browser-only APIs such as window and localStorage behind afterNextRender or platform checks.
Static site generation (prerendering) renders routes to HTML at build time, so they can be served from a CDN with no server. Angular can prerender selected routes, including parameterised ones, and mix them with SSR and client-rendered routes through server route configuration.
A community meta-framework for Angular built on Vite, adding file-based routing, API routes, Markdown content and SSR or static generation. A good fit for content sites and blogs.
Angular protects against the most common web attacks by default: it escapes and sanitises everything bound into templates and cooperates with servers on CSRF tokens. Most vulnerabilities in Angular apps come from bypassing those defaults or from the backend.
XSS injects attacker script into your page. Angular treats every bound value as untrusted, escaping interpolation and sanitising [innerHTML]. Avoid direct DOM manipulation with ElementRef and never build templates from user input.
When a value is bound to HTML, style, URL or resource URL contexts, Angular strips anything dangerous such as <script> tags or javascript: URLs and logs a warning in development.
DomSanitizer.bypassSecurityTrustHtml (and its URL, style and resource URL siblings) marks a value as safe. Use it only on content you control or have sanitised yourself, because it switches off Angular's protection.
A Content Security Policy with require-trusted-types-for 'script' makes the browser reject raw strings in DOM sinks. Angular supports it with named policies such as angular, so you can lock down XSS at the browser level.
Two request-level attacks matter most for an Angular client: cross-site request forgery and cross-site script inclusion. Both need server cooperation, and HttpClient has helpers for each.
Another site tricks a signed-in user's browser into sending a request with their cookies. Defend with SameSite cookies plus a token the attacker cannot read, which the server checks on every state-changing request.
HttpClient reads a token from the XSRF-TOKEN cookie and sends it as the X-XSRF-TOKEN header on mutating requests to relative URLs. The server must set the cookie and verify the header.
Customise the cookie and header names with withXsrfConfiguration({ cookieName, headerName }), or turn the feature off with withNoXsrfProtection() when your backend uses another scheme.
XSSI, or JSON hijacking, loads a JSON API as a <script> from another origin. Servers defend by prefixing responses with )]}', followed by a newline, and HttpClient strips that prefix before parsing.
Build on native semantics first, then add ARIA where you build custom widgets. The Angular CDK provides focus traps, live announcers and keyboard managers, and the Angular Aria package adds headless accessible patterns. After route changes, move focus deliberately so assistive tech notices the new page.
ARIA attributes have no DOM property counterpart, so bind them with [attr.aria-expanded] or the aria-* property bindings Angular supports. Static values can be written as plain attributes.
Angular Material and the CDK implement keyboard support, focus handling and ARIA roles for common widgets. Use them, or follow the WAI-ARIA patterns closely when building your own.
Prefer enhancing a native element with an attribute selector, such as button[appButton], over wrapping it in a custom element. When you must wrap, project the native control with <ng-content> so its semantics survive.
Give links text that makes sense out of context, and mark the current page with routerLinkActive plus ariaCurrentWhenActive="page" so screen readers announce which link is active.
Angular performance comes down to shipping less JavaScript up front and doing less change detection at runtime. Measure first with Chrome's performance panel and Angular DevTools' profiler, then apply the targeted fixes below.
Wrap heavy, below-the-fold parts of a page in @defer (on viewport) with a sized @placeholder. Their code moves to a separate chunk and loads only when needed, improving initial load metrics.
NgOptimizedImage (ngSrc) enforces width and height to prevent layout shift, lazy-loads by default, adds priority hints for the LCP image and generates srcset through an image CDN loader.
Third-party libraries and setInterval calls can trigger change detection many times a second under zone.js. Spot it in the profiler and run that code inside NgZone.runOutsideAngular.
Expensive template expressions or getters run on every check. Move them into computed signals or pure pipes, which recalculate only when inputs change, and use OnPush to skip whole subtrees.
With SSR, provideClientHydration() reuses the server-rendered DOM instead of rebuilding it, avoiding flicker. withEventReplay() captures early clicks, and incremental hydration with @defer (hydrate on ...) delays hydrating parts until needed.
Angular tests run on TestBed, which builds a test module with real or fake providers. Recent CLI versions use Vitest as the default runner; older projects use Karma and Jasmine. Component harnesses from the CDK make tests resilient to markup changes.
Services without dependencies can be created with new and tested as plain classes. Use TestBed.inject when you want Angular's DI to wire things the same way as the app.
Replace collaborators with fakes through providers: [{ provide: Api, useValue: fakeApi }] in TestBed.configureTestingModule, so each test controls exactly what its dependencies return.
A pure pipe is a class with a transform method: instantiate it and assert on outputs for edge cases. Add a small host component test only if the pipe depends on DI or locale.
Provide provideHttpClient() and provideHttpClientTesting(), then use HttpTestingController to expectOne a URL, flush a fake response and verify() that no unexpected requests remain.
Declare a tiny host component that applies the directive in a few configurations, then query the elements and assert on classes, styles or behaviour after fixture.detectChanges().
Create the component with TestBed.createComponent, trigger rendering with fixture.detectChanges() or await fixture.whenStable(), and query the DOM through fixture.nativeElement or debugElement.query(By.css(...)).
Set inputs with fixture.componentRef.setInput(), dispatch DOM events to test outputs and event bindings, and assert that the rendered text and emitted values match.
Run a single file or test in watch mode, add debugger statements and open the test browser's DevTools, or attach your editor's debugger. Missing provider errors usually mean the test module lacks a dependency.
Generate a coverage report from ng test with the coverage option and set minimum thresholds in the configuration so coverage cannot silently drop. Treat the number as a guide, not a goal.
Angular's built-in i18n marks text in templates and code, extracts it into translation files and builds a separate, fully translated bundle per locale at compile time. Locale data also drives date, number and currency formatting in pipes.
ng add @angular/localize installs the package that powers the i18n template attribute and the $localize tagged template for strings in TypeScript.
Locales use Unicode locale identifiers such as en-US or fa-IR. Set the source locale in angular.json; LOCALE_ID then determines formatting rules for the built bundle.
ng extract-i18n writes the source messages to XLIFF (or XMB or JSON). Copy the file per language, have translators fill in targets, and give messages custom IDs so they survive text edits.
Configure localize in angular.json to build every locale in one run, then deploy each bundle under its own path such as /fa/ and route users with server rules or a language switcher.
Angular now favours native CSS animations, with animate.enter and animate.leave to apply classes when elements are added or removed. The older @angular/animations package, with its trigger-based DSL, is still found in many codebases and is documented as legacy.
In @angular/animations, a trigger defines named states and transitions between them, applied with [@openClose]="isOpen". Special transitions such as :enter and :leave animate elements being added and removed.
Coordinate multiple elements with query() to find children, stagger() to offset them, and group() or sequence() to run steps in parallel or in order, as in a list that animates in item by item.
Define an animation once with animation() and parameters, then apply it in different triggers with useAnimation(). With CSS animations, shared keyframes and classes play the same role.
Animate between pages with the browser's View Transitions API by adding withViewTransitions() to provideRouter, then style the transition with ::view-transition pseudo-elements in CSS.