Friday, 16 May 2025

Angular 17 uses stand alone component no more module


HTTP provider not included

Standalone 17+ no longer auto-include HTTP providers.


You must explicitly register them with provideHttpClient() (or import the old module).


Without that, any constructor injection of HttpClient (or its alias _HTTPClient) fails with


NullInjectorError: No provider for _HTTPClient!

Router not included in standalone

When you go fully-standalone in Angular, the router isn’t automatically wired up for you the way it used to be in an NgModule. You need two things:

  1. Provide your routes at bootstrap

  2. Import the router directives (RouterOutlet, RouterLink, etc.) into your root (and any other) components

No comments:

Post a Comment