Hi I have a login component that contains link to the register component.
When I click on this link I got this issue:
ERROR Error: Uncaught (in promise): Error: No provider for HttpClient!
Error: No provider for HttpClient!
at injectionError (core.es5.js:1169)
at noProviderError (core.es5.js:1207)
at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_._throwOrNull (core.es5.js:2649)
at ReflectiveInjector_.webpackJsonp.../../../core/@angular/co...
The login component is well loaded, the register fails.
on the login component html I have:
<a [routerLink]="['/register']" class="btn btn-link">Register</a>
my app routing looks like this:
const appRoutes: Routes = [
{ path: '', component: HomeComponent, canActivate: [GuardService] },
{ path: 'login', component: LoginComponent },
{ path: 'register', component: RegisterComponent },
// otherwise redirect to home
{ path: '**', redirectTo: '' }
];
export const routing = RouterModule.forRoot(appRoutes);
The versions I am using: Node.js version: v8.5.0 NPM version: 5.4.2
Thanks!
Ensure HttpClientModule
is listed in imports
:
@NgModule({
imports: [BrowserModule, HttpClientModule, ...],
})
export class AppModule{}