📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

What are the building blocks of an Angular application: components, templates and data binding, services, dependency injection, HttpClient and signals? How does Angular call an ASP.NET Core API, and how does it compare with React for a .NET team?

Angular fundamentals for a .NET developer: standalone components, templates and binding, services and hierarchical DI, HttpClient with interceptors, signals and zoneless change detection, and a comparison with React.

Junior Theory Beginner angular dependency-injection frontend httpclient signals typescript

🎯 Key points

  • Standalone components (TypeScript class + template + styles) are the default; NgModules are legacy
  • Template binding: interpolation, [property], (event), built-in @if / @for with track
  • Services marked @Injectable({ providedIn: 'root' }) and injected with inject(); hierarchical injectors mirror .NET lifetimes
  • HttpClient returns cold RxJS Observables; functional interceptors add credentials or tokens and map errors
  • Signals (signal, computed, effect) drive fine-grained, zoneless change detection (default for new apps since Angular 21)
  • Router with lazy-loaded routes and guards (canActivate, canMatch) for navigation, not security
  • Angular is a full framework with opinions (router, forms, DI, testing); React is a library you assemble
  • As of November 2026 Angular 22 is current; majors move to a yearly cycle, Angular 23 planned for mid-2027

⏱ 30-second answer

Angular is a full framework. An app is a tree of standalone components, each a TypeScript class with a template that binds data: {{ value }} for text, [property] for inputs, (event) for outputs. Logic and data access live in services that Angular's dependency injection supplies, with root-level singletons and component-level providers, which feels very familiar to .NET developers.

The API is called through HttpClient, which returns RxJS Observables and supports interceptors for auth headers and error handling. Modern Angular uses signals for state and zoneless change detection (the default for new apps since Angular 21; Angular 22 is current).

Compared with React, Angular gives you the router, forms, DI and testing out of the box, at the cost of more concepts (RxJS, decorators) and a steeper start.

🗣 Full answer (senior)

How I would answer this in an interview

"Angular is the frontend framework that feels most like ASP.NET Core. You build standalone components: a TypeScript class with a template and styles, declared with the @Component decorator. The template binds to the class: double braces for text, square brackets for properties, round brackets for events. Shared logic goes in services, which Angular creates and injects, so I mark a service @Injectable({ providedIn: 'root' }) to get an app-wide singleton, or provide it on a component to get one instance per component subtree. That hierarchy is Angular's version of lifetimes.

To call my ASP.NET Core API, I inject HttpClient into a service such as OrdersService and expose methods returning typed Observables. Cross-cutting things go in interceptors, which are like DelegatingHandlers: one adds the antiforgery header or bearer token, another maps 401 to a redirect and ProblemDetails to friendly messages. In current Angular, state increasingly lives in signals: signal(), computed() and effect(). With signals Angular knows exactly which views depend on which values, so new apps run zoneless without zone.js patching every async API.

The mistake I see is people subscribing to Observables manually in components and never unsubscribing, which leaks memory and fires duplicate requests. Use the async pipe, toSignal() or takeUntilDestroyed(). Compared with React, Angular is opinionated: one router, one forms story, one DI container. For a large .NET team that consistency is often worth the steeper learning curve."


Building blocks

Concept What it does .NET analogy
Standalone component Class + template + styles Razor component
Template binding {{ }}, [prop], (event), @if, @for Razor syntax
Service + @Injectable Reusable logic, data access Registered service
providedIn: 'root' App-wide singleton AddSingleton
Component providers One instance per component subtree Roughly AddScoped per scope
HttpClient + interceptors HTTP with a pipeline HttpClient + DelegatingHandler
Signals Reactive state with fine-grained updates INotifyPropertyChanged, but automatic
Router + guards Navigation, lazy loading, route protection Endpoint routing + filters

Angular vs React for a .NET team

Dimension Angular React
Scope Full framework UI library plus your choices
DI Built in, hierarchical None (Context, props)
Async model RxJS Observables + signals Promises + hooks
Forms Reactive forms, signal forms (stable in v22) Third-party (React Hook Form)
Learning curve Steeper at the start Easier start, more decisions later
Hiring in Australia Common in enterprise and government Most common overall

As of November 2026, Angular 22 is current; the team has moved to a yearly major cycle, with Angular 23 expected around mid-2027.

Production example

On a government portal with [N] developers, moving auth and error handling into two HttpClient interceptors removed about 40 copies of try/catch and header code from components, and replacing manual subscriptions with toSignal() fixed a leak that grew the tab's memory by roughly 150 MB over a working day.

🔍 What the interviewer is checking

Checks whether the candidate can read and work in an Angular codebase that calls their API and can compare it fairly with React.

Green flags

  • Explains components, templates, services and hierarchical DI, and maps them to .NET concepts
  • Knows HttpClient returns cold Observables and how interceptors work
  • Mentions signals, standalone components and zoneless change detection as the current model
  • Compares Angular and React on scope, conventions and team fit, not hype

Red flags

  • Describes only AngularJS (1.x) concepts such as $scope
  • Subscribes everywhere without unsubscribing
  • Claims route guards protect data
  • Cannot explain the difference between a framework and a library

📚 Learn in depth

1. Components and templates

A standalone component declares its own imports, so there is no NgModule to maintain. Templates use the built-in control flow @if, @for (item of items; track item.id) and @switch. The track expression plays the same role as React's key.

2. Change detection: from zone.js to signals

Classic Angular used zone.js to monkey-patch setTimeout, promises and DOM events, then re-check the whole component tree after any async work. It was simple but wasteful.

old:  any async event ──► zone.js ──► check every component
new:  signal.set(x) ──► Angular marks only dependent views ──► update

With signals, a template that reads orders() registers a dependency. When orders.set(...) runs, only those views are marked dirty. New apps are zoneless by default since Angular 21.

3. Dependency injection

Angular has a tree of injectors: the environment (root) injector and an element injector per component. When a component asks for a service, Angular walks up the tree until a provider is found. Providing a service on a component gives each instance of that component its own copy, which is useful for per-screen state such as a wizard. inject() is the modern way to request a dependency inside a constructor context or field initialiser.

4. HttpClient and RxJS

HttpClient.get<T>() returns a cold Observable: nothing is sent until someone subscribes, and each subscription sends a new request. Operators such as switchMap cancel the previous request when a new search term arrives, the equivalent of aborting with a CancellationToken. Interceptors are functions registered with provideHttpClient(withInterceptors([...])). Angular's HttpClient can also read the XSRF-TOKEN cookie and send it as the X-XSRF-TOKEN header, which matches what ASP.NET Core antiforgery can be configured to expect.

5. Bridging Observables and signals

toSignal(observable) subscribes and unsubscribes with the component's lifetime; toObservable(signal) goes the other way. The new httpResource() and resource() APIs wrap requests as signals with loading and error state.

6. Tooling

The Angular CLI (ng new, ng generate, ng build) uses esbuild and Vite under the hood. In development, proxy.conf.json forwards /api to the ASP.NET Core backend so the browser sees one origin.

Try it yourself

  1. ng new orders --standalone and generate an OrdersService with ng g s orders.
  2. Call a Minimal API from the service and render the result with toSignal() and @for ... track.
  3. Add an interceptor that logs every request duration to the console.
  4. Type quickly into a search box wired with switchMap and watch cancelled requests in the Network tab.
  5. Provide a service on a component instead of root and log its constructor to see how many instances you get.

💻 Code

A Minimal API endpoint and an Angular service, component, interceptor and lazy-loaded route calling it.

// Program.cs (.NET 10)
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/api/orders", () =&gt; TypedResults.Ok(new OrderDto[]
{
    new(1, "ACME Pty Ltd", 120.50m),
    new(2, "Bondi Bikes", 89.00m),
}));

app.Run();

public sealed record OrderDto(int Id, string Customer, decimal Total);
// orders.service.ts
import { Injectable, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';

export interface Order { id: number; customer: string; total: number; }

@Injectable({ providedIn: 'root' }) // app-wide singleton, like AddSingleton
export class OrdersService {
  private readonly http = inject(HttpClient);
  getOrders() { return this.http.get

⚠ Common mistakes

  • Mistake: Calling .subscribe() in a component and never unsubscribing. Why it is wrong: Long-lived Observables keep the component alive and keep firing. Instead: Use the async pipe, toSignal() or takeUntilDestroyed().
  • Mistake: Subscribing twice to the same HttpClient Observable. Why it is wrong: HttpClient Observables are cold, so each subscription sends another request. Instead: Subscribe once, or share the result with a signal or shareReplay.
  • Mistake: Starting new code with NgModules and zone.js-dependent patterns. Why it is wrong: Standalone components and zoneless change detection are the defaults; old patterns add weight. Instead: Use standalone components, signals and the built-in control flow.
  • Mistake: Putting HTTP calls and business logic directly in components. Why it is wrong: It is hard to test and duplicates code. Instead: Put data access in services and cross-cutting concerns in interceptors.
  • Mistake: Providing a stateful service on a component by accident. Why it is wrong: Each component instance gets its own copy, so state appears to reset. Instead: Choose providedIn: 'root' or component providers deliberately, as you would choose a .NET lifetime.
  • Mistake: Relying on route guards for security. Why it is wrong: Guards only control navigation in the browser. Instead: Enforce authorisation in the ASP.NET Core API.

🏛 Senior insight: trade-offs

For .NET teams Angular's main selling point is not technical superiority but consistency: DI, typed services, one router with lazy loading and guards, one forms story and a CLI that generates the same structure every time. That reduces design debate on large teams and makes onboarding .NET developers easier. The cost is RxJS, which many developers use badly; modern Angular reduces that by pushing signals for state and keeping RxJS for genuinely stream-shaped problems such as search-as-you-type.

Error handling splits cleanly: the ASP.NET Core API returns ProblemDetails with the right status code, and one Angular interceptor turns 401 into a redirect and 400 validation errors into field messages, so components never parse HTTP errors themselves. Versions checked November 2026: Angular 22 is current, and from v22 Angular moved to a yearly major cycle, so Angular 23 is planned for around mid-2027.

When I compare frameworks I look at the team and the next five years, not benchmarks: who will maintain it, what the organisation already runs, and the hiring market.

Option When it fits Cost When not to
Angular Large teams, long-lived enterprise apps, strong appetite for conventions Steeper learning, RxJS Small marketing sites, quick prototypes
React Wide talent pool, varied UIs, need for ecosystem choice Many decisions to standardise Teams that will not invest in conventions
Blazor .NET-only team, internal LOB apps Smaller ecosystem, WebAssembly download or server circuits Public sites needing fast first load on mobile

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions HttpClient's XSRF support or cookies. Why: Checks how antiforgery tokens flow from ASP.NET Core to an SPA and why SameSite alone is not enough.
    How to answer

    CSRF makes a victim's browser send a state-changing request to your site from another site; it works because the browser attaches cookies automatically. If you authenticate with cookies, you're exposed; if callers send a bearer token in the Authorization header, a cross-site page can't add it, so classic CSRF doesn't apply.

    ASP.NET Core's antiforgery uses a synchroniser token: a cookie token plus a token in the form or a header, validated together. MVC forms get it from the form tag helper with [ValidateAntiForgeryToken] or the global auto-validate filter; Razor Pages validate POSTs by default; Minimal APIs need AddAntiforgery/UseAntiforgery and validate form-bound endpoints. SameSite=Lax (the default for ASP.NET Core auth cookies) blocks most cross-site POSTs, but not attacks from a sibling subdomain or GETs that change state, so keep tokens.

  2. When: Candidate runs the Angular dev server on a different port from the API. Why: Checks understanding of CORS and why a dev proxy avoids it.
    How to answer

    The same-origin policy stops JavaScript on one origin (scheme + host + port) from reading responses from another, so a malicious page can't read your bank's API with your cookies. CORS is the server's way to opt in. For a simple request (GET, HEAD or POST with only safelisted headers and a form or text/plain body) the browser sends it and then checks Access-Control-Allow-Origin before handing the response to your code. Anything else, such as a JSON POST, a PUT or an Authorization header, first gets an OPTIONS preflight asking permission for that method and those headers. Sending cookies needs credentials: 'include' and Access-Control-Allow-Credentials: true with an explicit origin. The key trade-off: the browser enforces it but the server's headers decide, and CORS is not security for your API: non-browser clients ignore it.

  3. When: Candidate mentions signals or zoneless change detection. Why: Checks understanding of fine-grained reactivity and why zone.js was dropped.
    How to answer

    A signal is a value wrapper that tracks who reads it: count = signal(0), read with count(), change with set or update. computed() derives values lazily and memoises them, and effect() runs side effects. When a template reads a signal, Angular records the dependency, so a change marks only the views that use it.

    With zone.js, Angular patched every async API (timers, promises, DOM events) and ran change detection over the component tree after any of them, whether or not data changed. Signals enable zoneless change detection, the default for new apps since Angular 21 (checked November 2026; existing apps can still run with zone.js and migrate gradually). The benefits are fewer checks, a smaller bundle without zone.js, clearer stack traces and simpler state: plain signals in a service replace many hand-rolled BehaviorSubject stores. RxJS remains the tool for event streams.

↩ Usually asked after

More in SPA Integration

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me