Skip to main content

Angular Reference

v1.0.0

Quick reference for Angular components, services, directives, and RxJS patterns

Angular quick-reference covering components, services, dependency injection, directives, pipes, routing, RxJS operators, reactive forms, and the signals API. Search and filter entries by name or category.

How to use
  • Type in the search box to filter entries by name, syntax, or description.
  • Click a category chip to narrow results — click again to clear the filter.
  • Expand any entry to see a syntax snippet and a practical code example.
  • Use the example picker for preset filter scenarios.

44 entries found

@Component
Components

@Component({ selector, template, styles })

Decorator that marks a class as an Angular component with metadata for template, styles, and selector.

@Input()
Components

@Input() propertyName: Type

Decorator that marks a class property as an input binding, allowing parent components to pass data.

@Output()
Components

@Output() eventName = new EventEmitter<Type>()

Decorator that marks a property as an output event that the component can emit to its parent.

ngOnInit / ngOnDestroy
Components

ngOnInit(): void / ngOnDestroy(): void

Lifecycle hooks called after data-bound properties are set (init) and before the component is destroyed.

@ViewChild()
Components

@ViewChild(selector) prop: ElementRef

Access a child component, directive, or DOM element from the component class.

Content Projection
Components

<ng-content select="selector"></ng-content>

Project external content into a component template using slots.

@Injectable()
Services & DI

@Injectable({ providedIn: 'root' })

Decorator that marks a class as injectable and optionally registers it with the root injector.

inject()
Services & DI

const service = inject(ServiceToken)

Functional API to inject a dependency in components, directives, or other injectables (Angular 14+).

InjectionToken
Services & DI

new InjectionToken<Type>('description')

Create a typed token for non-class dependencies (e.g. config objects, API URLs).

HttpClient
Services & DI

this.http.get<T>(url, options)

Service for making HTTP requests. Returns Observables. Must import HttpClientModule.

provideHttpClient()
Services & DI

provideHttpClient(withInterceptors([...]))

Standalone provider function for HttpClient (Angular 15+). Replaces HttpClientModule.

*ngIf
Directives

*ngIf="condition; else elseRef"

Structural directive that conditionally renders elements. Removes/adds from the DOM.

*ngFor
Directives

*ngFor="let item of items; trackBy: trackFn"

Structural directive that repeats a template for each item in a collection.

@for (control flow)
Directives

@for (item of items; track item.id) { }

Built-in control flow block (Angular 17+). Replaces *ngFor with better performance.

@if (control flow)
Directives

@if (cond) { } @else if (cond) { } @else { }

Built-in control flow block (Angular 17+). Replaces *ngIf with cleaner syntax.

@switch (control flow)
Directives

@switch (expr) { @case (val) { } @default { } }

Built-in control flow block (Angular 17+). Replaces ngSwitch directives.

[ngClass] / [ngStyle]
Directives

[ngClass]="expr" [ngStyle]="expr"

Attribute directives that dynamically apply CSS classes or inline styles.

date
Pipes

{{ value | date:'format' }}

Formats a date value according to locale rules and a format string.

async
Pipes

{{ observable$ | async }}

Subscribes to an Observable or Promise, returns the latest value, and unsubscribes on destroy.

json
Pipes

{{ value | json }}

Converts a value to a JSON string. Useful for debugging object values in templates.

currency / number / percent
Pipes

{{ val | currency:'USD' }} {{ val | number:'1.2-2' }}

Locale-aware number formatting pipes for currency, decimals, and percentages.

Custom pipe
Pipes

@Pipe({ name: 'pipeName', standalone: true })

Create a reusable transformation pipe. Must implement PipeTransform interface.

provideRouter()
Routing

provideRouter(routes, withFeatures(...))

Standalone provider function for the Angular router (replaces RouterModule).

RouterLink / RouterOutlet
Routing

<a routerLink="/path"> <router-outlet />

Directive for declarative navigation and placeholder for routed component rendering.

ActivatedRoute
Routing

inject(ActivatedRoute).params

Service that provides access to route parameters, query params, and route data.

Route Guards
Routing

canActivate: [() => inject(AuthService).isLoggedIn()]

Functional guards (Angular 15+) that control route activation, deactivation, and data resolution.

Lazy Loading
Routing

loadComponent: () => import('./path').then(m => m.Comp)

Dynamically load routes or components to reduce initial bundle size.

map
RxJS Operators

pipe(map(val => transform(val)))

Transform each emitted value using a projection function.

switchMap
RxJS Operators

pipe(switchMap(val => innerObs$))

Map each value to an Observable, subscribing to the latest and cancelling previous inner subscriptions.

combineLatest
RxJS Operators

combineLatest([obs1$, obs2$])

Combine the latest values from multiple Observables. Emits when any source emits.

takeUntilDestroyed
RxJS Operators

pipe(takeUntilDestroyed(destroyRef))

Automatically unsubscribe when the component is destroyed (Angular 16+). Replaces manual unsubscribe patterns.

catchError
RxJS Operators

pipe(catchError(err => fallback$))

Handle errors in an Observable chain. Must return a new Observable or rethrow.

Subject / BehaviorSubject
RxJS Operators

new BehaviorSubject<Type>(initial)

Multicasting Observables. BehaviorSubject holds the current value and emits it to new subscribers.

FormGroup / FormControl
Reactive Forms

new FormGroup({ key: new FormControl(value) })

Core building blocks for reactive forms. FormGroup tracks the state of a group of FormControl instances.

FormBuilder
Reactive Forms

this.fb.group({ key: [value, validators] })

Shorthand service for creating FormGroup, FormControl, and FormArray instances.

FormArray
Reactive Forms

new FormArray([control1, control2])

Tracks an array of AbstractControl instances. Useful for dynamic lists of form fields.

Validators
Reactive Forms

Validators.required | .email | .min(n) | .pattern(regex)

Built-in validators for form controls. Can compose multiple validators in an array.

Custom Validator
Reactive Forms

(control: AbstractControl): ValidationErrors | null

Create reusable validation functions. Return null for valid, or an error object for invalid.

signal()
Signals

const name = signal<Type>(initialValue)

Create a reactive signal (Angular 16+). Read by calling the signal function, write with .set() or .update().

computed()
Signals

const derived = computed(() => expr)

Create a read-only signal derived from other signals. Automatically tracks dependencies.

effect()
Signals

effect(() => { /* read signals here */ })

Run a side effect whenever tracked signals change. Automatically cleaned up on destroy.

input() / output()
Signals

name = input<Type>(default) / clicked = output<Type>()

Signal-based input and output declarations (Angular 17.1+). Replaces @Input() and @Output() decorators.

toSignal() / toObservable()
Signals

toSignal(obs$) / toObservable(sig)

Bridge between RxJS Observables and Signals. Convert in either direction.

linkedSignal()
Signals

linkedSignal(() => sourceSignal())

Create a writable signal that resets to a computed value when dependencies change (Angular 19+).