2017-09-29 15 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上:

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

私が使用していたバージョン: Node.jsのバージョン:V8.5.0 NPMを

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

私のアプリルーティングは次のようになりますバージョン:5.4.2

ありがとうございます!

答えて

8

HttpClientModuleimportsにリストされていることを確認します

@NgModule({ 
    imports: [BrowserModule, HttpClientModule, ...], 
}) 
export class AppModule{} 

も参照してくださいhttps://angular.io/api/common/http/HttpClient

1

HttpModuleを確認して、ルーティングは輸入に記載されています。

関連する問題