mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
The "Providing HttpClient through dependency injection" documentation now shows that in case of a standalone boostraped app, the provideHttpClient is to include in the app.config.ts file. Also updated the http setup server communication example to align the new doc (adev) with the old one (aio). PR Close #52806
1.2 KiB
1.2 KiB
HTTP: Setup for server communication
Before you can use HttpClient, you must add it to the application's root dependency injector.
Most apps do so in the providers array of ApplicationConfig in app.config.ts.
You can then inject the HttpClient service as a dependency of an application class, as shown in the following ConfigService example.
You can run the that accompanies this guide.
The sample app does not require a data server.
It relies on the Angular in-memory-web-api, which replaces the HttpClient module's HttpBackend.
The replacement service simulates the behavior of a REST-like backend.
Look at the bootstrapApplication() method in main.ts to see how it is configured.
@reviewed 2023-08-16