Angular essentials: 50 cards on signals, components and RxJS
Modern Angular: standalone components, signals, inputs and outputs, dependency injection, RxJS basics, @if and @for, routing and OnPush change detection.
Practice now
Study without an account
Scheduled with the default Askesis timings. Progress is saved in this browser.
All 50 cards
- 1What is an Angular component?A TypeScript class with the
@Componentdecorator that ties together a CSS selector, a template and stylests@Component({ selector: "app-hello", template: `<h1>Hello {{ name }}</h1>`, }) export class Hello { name = "Ada" } - 2What is a standalone component?A component that lists its own dependencies in
importsinstead of being declared in anNgModuleNew projects use them since Angular 17, and since v19standalone: trueis the default, so you no longer write it. - 3Bootstrap a standalone Angular appts
bootstrapApplication(App, { providers: [provideRouter(routes), provideHttpClient()], }) - 4Template syntax:
{{ }},[ ]and( ){{ total }}interpolates text;[disabled]="busy"binds a property;(click)="save()"listens to an event - 5What is
[(ngModel)]?Two-way binding (“banana in a box”): a property binding plus an event binding in one.ngModelneedsFormsModulein the component’simports - 6Show content conditionally with built-in control flowhtml
@if (user) { <p>Hi {{ user.name }}</p> } @else { <button (click)="login()">Log in</button> }Built-in control flow arrived in Angular 17 (stable in 18) and replaces*ngIf. - 7Render a list with
@forhtml@for (item of items; track item.id) { <li>{{ item.name }}</li> } @empty { <li>No items yet</li> } - 8Why does
@forrequiretrack?It identifies each item so Angular can keep and move existing DOM nodes when the list changes instead of re-creating them. Track a unique IDtrack $indexis only fine for static lists. - 9Implicit variables available inside
@for$index,$first,$last,$even,$oddand$count - 10What does
@deferdo?Lazy-loads the components, directives and pipes inside the block in a separate chunk when a trigger fires, likeon viewportoron interactionThe default trigger ison idle. Optional@placeholder,@loadingand@errorblocks show other states. - 11What does
@letdo in a template?Declares a read-only local variable:@let total = price() * qty();(Angular 18.1+) - 12Create, read and update a signalts
count = signal(0) this.count() // read: call it this.count.set(5) this.count.update((c) => c + 1)Reading a signal in a template or acomputedregisters it as a dependency. - 13What does
computed()create?A read-only signal derived from other signals; it is evaluated lazily, memoized and recalculated only when a dependency changestsfullName = computed(() => `${this.first()} ${this.last()}`) - 14What is
effect()for?Running side effects, like logging or syncing tolocalStorage, whenever the signals it reads change; it always runs at least onceDon’t use effects to copy one signal into another; usecomputedorlinkedSignal. - 15Why doesn’t the template update?ts
items = signal<string[]>([]) add(x: string) { this.items().push(x) }Mutating the array in place doesn’t notify the signal. Set a new value:this.items.update((list) => [...list, x]) - 16Declare signal inputsts
name = input<string>() // optional userId = input.required<number>() // must be boundThe parent binds<app-user [userId]="id" />and the child readsthis.userId(). The older@Input()decorator still works. - 17Emit an event from a child with
output()tssaved = output<User>() this.saved.emit(user)The parent listens with(saved)="onSaved($event)". - 18What does
model()create?A writable signal input that supports two-way binding: the child callsvalue.set(…)and the parent binds with[(value)]="count" - 19What is dependency injection in Angular?Classes declare what they need and Angular’s injector creates and supplies the instances, so components never construct services themselvesThis makes services easy to share and to replace with fakes in tests.
- 20Inject a dependency with
inject()tsexport class UserList { private http = inject(HttpClient) }inject()only works in an injection context: field initializers, constructors and provider factories. - 21What does
@Injectable({ providedIn: "root" })do?Registers the service with the root injector: one shared instance for the whole app, and tree-shaken away if nothing injects it - 22What happens when a component lists a service in its own
providers?Each instance of that component gets its own service instance, shared with its child components (hierarchical injectors) - 23What is an Angular service?A class, usually
@Injectable, that holds logic or state shared across components, like data access, caching or logging - 24Provide a non-class value, like a config URLts
export const API_URL = new InjectionToken<string>("API_URL") // providers: [{ provide: API_URL, useValue: "https://api.example.com" }] private apiUrl = inject(API_URL) - 25Observable vs PromiseAn Observable is lazy, can emit many values over time and is cancelled by unsubscribing; a Promise starts immediately and settles once
- 26Why is no request sent?ts
loadUsers() { this.http.get<User[]>("/api/users") }HttpClientreturns a cold Observable: nothing happens until something subscribes, for example.subscribe(), theasyncpipe ortoSignal() - 27What does
switchMapdo?Maps each value to an inner Observable and unsubscribes from the previous one, cancelling stale requests; ideal for search-as-you-typetsresults$ = this.query$.pipe( debounceTime(300), switchMap((q) => this.api.search(q)), ) - 28
mergeMapvsconcatMapvsexhaustMapmergeMapruns inner Observables concurrently;concatMapqueues them in order;exhaustMapignores new values while one is still runningexhaustMapsuits a submit button that shouldn’t fire twice. - 29Three ways to avoid leaking subscriptions in a componentThe
asyncpipe,takeUntilDestroyed()in the pipe, ortoSignal(): each unsubscribes automatically when the component is destroyed - 30What does
toSignal()do?Subscribes to an Observable and exposes its latest value as a signal, unsubscribing on destroy; the value isundefineduntil the first emission unless you passinitialValueIt andtoObservable()come from@angular/core/rxjs-interop. - 31What is a
BehaviorSubject?A Subject that needs an initial value, stores the latest value and emits it immediately to every new subscriber - 32What does
{{ user$ | async }}do?Subscribes touser$, renders its latest value, marks the view for checking on each emission and unsubscribes when the component is destroyedThe$suffix is a naming convention for Observables. - 33Define routes, including a 404 pagets
export const routes: Routes = [ { path: "", component: Home }, { path: "users/:id", component: UserDetail }, { path: "**", component: NotFound }, ]The first matching route wins, so the**wildcard goes last. - 34Lazy-load a route’s componentts
{ path: "admin", loadComponent: () => import("./admin/admin").then((m) => m.Admin), }UseloadChildrento lazy-load a whole set of child routes. - 35Where do routed components render, and how do you link to them?Inside
<router-outlet />; link withrouterLink="/users"or navigate in code withrouter.navigate(["/users", id]) - 36Read the
:idroute parametertsprivate route = inject(ActivatedRoute) id = this.route.snapshot.paramMap.get("id")WithprovideRouter(routes, withComponentInputBinding()), a matchingid = input<string>()receives it directly. - 37Protect a route with a guardts
export const authGuard: CanActivateFn = () => inject(Auth).isLoggedIn() || inject(Router).createUrlTree(["/login"]) // { path: "admin", canActivate: [authGuard], … }Returning aUrlTreeredirects instead of just blocking. - 38What is change detection?Angular checking component templates for bindings whose values changed and updating the DOM to match
- 39What does Zone.js do for Angular?It patches async browser APIs (events, timers, promises, XHR) so Angular knows when to run change detectionZoneless change detection, driven by signals and events, is stable since Angular 20.2 and the default for new apps since v21.
- 40When is an
OnPushcomponent checked?When an input gets a new reference, an event fires in it or its children, a signal read in its template changes, anasyncpipe emits, ormarkForCheck()is called - 41With
OnPush, why doesn’t the child update?tsthis.user.name = "Grace" // user is passed as an inputThe input still holds the same object reference, soOnPushsees no change. Pass a new object:this.user = { ...this.user, name: "Grace" } - 42
constructorvsngOnInitUse the constructor (or field initializers) for injection;ngOnInitruns once after the first input values are set, so initialization that needs inputs goes thereWith signal inputs you can often usecomputedinstead. - 43What are
ngOnChangesandngOnDestroyfor?ngOnChangesruns whenever bound inputs change, first beforengOnInit;ngOnDestroyruns just before the component is removed, for cleanup - 44Register cleanup without implementing
ngOnDestroytsinject(DestroyRef).onDestroy(() => clearInterval(this.timer)) - 45What does
<ng-content />do?Content projection: it renders the markup the parent puts between the component’s tagsUse<ng-content select="[card-title]" />for several named slots. - 46What is a pipe?A template function that transforms a value for display, like
{{ price | currency: "EUR" }}or{{ when | date: "short" }}Pipes are pure by default: they re-run only when the input value or reference changes. - 47What is
#boxin<input #box />?A template reference variable: it refers to the element (or component) elsewhere in the template, e.g.(click)="search(box.value)" - 48Are component styles global?No. With the default
ViewEncapsulation.Emulated, Angular adds generated attributes so a component’s styles apply only to its own template - 49Common Angular CLI commands
ng newcreates a project,ng serveruns the dev server,ng generate component name(ng g c) scaffolds,ng buildbuilds for production - 50Are
*ngIfand*ngForstill recommended?No. They are deprecated since Angular 20 in favor of@if,@forand@switch;ng generate @angular/core:control-flowmigrates templates
Frequently asked questions
Which Angular version does this deck cover?
Current Angular (v20 and later), with version notes where a feature arrived recently, such as built-in control flow (17), standalone by default (19) and zoneless apps (20.2 and 21).
Do I still need to learn RxJS?
Some. Signals now handle most component state, but HttpClient, the router and many libraries return Observables, so you should know subscribing, switchMap and how to avoid leaks.
Signals or Observables?
Signals for synchronous state that templates read; Observables for streams of events over time, like requests or keystrokes. toSignal and toObservable convert between them.
More in Web development
HTML & CSS
Fifty HTML and CSS cards: semantic HTML and accessible forms, specificity and cascade layers, flexbox and grid, stacking contexts and z-index, modern units and container queries.
50 cardsReact
Fifty React cards: state and re-rendering, useEffect and cleanup, memoization, refs, context, Suspense and the React 19 APIs like use, useOptimistic and useActionState.
50 cardsVue
Vue 3 fundamentals: ref vs reactive, computed and watch, props and emits, v-model, directives, slots, single-file components and Pinia stores.
50 cardsNext.js
Next.js App Router basics: server vs client components, layouts, route handlers, server actions, caching, metadata, dynamic routes and middleware.
50 cardsNode.js
Node.js fundamentals: the event loop, ESM vs CommonJS, npm, streams, Buffer, fs/promises, process, error handling, worker threads and a basic HTTP server.
50 cardsGraphQL
GraphQL basics: schema types, queries, mutations, subscriptions, resolvers, variables, fragments, N+1 and DataLoader, introspection and GraphQL vs REST.
50 cards