NG.VII · Angular 22 practice question

In an Angular application, you need to configure HTTP interactions. If you are using modern Angular practices and want to provide the `HttpClient` across your application modules or services, which approach should you use to set up the underlying HTTP infrastructure, and how does it differ from the older, more traditional module-based configuration?

Choose one answer
Check answer and explanation

Correct answer: Using `provideHttpClient()` in the application's standalone bootstrap function (`bootstrapApplication`), which leverages Injection Tokens to provide the HttpClient functionality directly without relying on NgModules.

Explanation

`provideHttpClient()` is the modern, standalone approach recommended in contemporary Angular versions (including Angular 22 features) to configure and provide the HttpClient infrastructure. It moves away from the explicit `HttpClientModule` structure found in NgModule-based setups, allowing for a cleaner, function-based setup directly in the bootstrap process.

Common trap

Many developers still default to using `HttpClientModule.forRoot()` learned from older tutorials, failing to recognize the shift toward functional providers like `provideHttpClient()` when building standalone applications.

Source: Angular Guide: HTTP (https://angular.dev/guide/http)
Checked against the cited text on 2026-11-27.

Report an error in this question