2017-09-29 61 views
2

您好我有一個登錄組件包含鏈接到註冊組件。ANGULAR 4路由問題:沒有供應商爲HttpClient

當我點擊這個鏈接,我得到了這個問題:

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... 

登錄組件非常加載,寄存器失敗。

在登錄組件的HTML

我:

<a [routerLink]="['/register']" class="btn btn-link">Register</a> 

我的應用程序的路由看起來是這樣的: Node.js的版本:V8.5.0 NPM

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); 

我使用的版本版本:5.4.2

謝謝!

回答

1

見確保HTTP模塊和路由進口上市。