NG.IV · Angular 22 practice question
A developer is building a large application and needs to ensure that a specific implementation of a service, like a custom LocationStrategy, is used across all parts of the application, even if individual modules might try to provide a different default. Where should this application-wide override be configured if the application is bootstrapped using `bootstrapApplication`?
bootstrapApplication(AppComponent, { providers: [{ provide: LocationStrategy, useClass: HashLocationStrategy }] });
Check answer and explanation
Correct answer: Within the `providers` array of the `ApplicationConfig` passed to `bootstrapApplication`.
Explanation
The configuration should be placed in the `providers` array of the `ApplicationConfig` passed to `bootstrapApplication` because this mechanism allows application-wide providers to override existing ones.
Common trap
Placing it in `@NgModule` providers is for NgModule-based setups, not the modern standalone bootstrapping approach described, and using `providedIn: 'root'` only registers the service but doesn't guarantee overriding a specific configuration like a router strategy.
Source: Angular docs: Hierarchical injectors — Platform injector
Checked against the cited text on 2026-11-25.