アプリの実行中は常にこのエラーが発生しますが、現在の開発では問題は発生していません(私はそう思います)このエラーを理解し、それがどこにあるのかを知りたいのです。完全に失われているため、関連する投稿すらできませんコード。でもやってみます.
したがって、これらはメインルート(appModule)です。
_const routes: Routes = [
{path:'home', component:HomeComponent, canActivate:[AuthGuardService]},
{path:'detail/:id', component:DetailComponent},
{path: 'register', component: RegisterComponent},
{path:'login', component: LoginComponent},
{path:'', redirectTo:'login', pathMatch: 'full'},
{path:'**', redirectTo:'login'}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
_
すべてのコンポーネントが登録されているコアモジュールがあり、RouterModule.forChild([])
をインポートしています:
_@NgModule({
declarations: [HomeComponent, DetailComponent, RegisterComponent, LoginComponent],
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
RouterModule.forChild([])
]
})
export class CoreModule { }
_
Package.json:
_{
"name": "mat-shop",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~9.1.9",
"@angular/cdk": "^9.2.4",
"@angular/common": "~9.1.9",
"@angular/compiler": "~9.1.9",
"@angular/core": "~9.1.9",
"@angular/forms": "~9.1.9",
"@angular/localize": "~9.1.9",
"@angular/material": "^9.2.4",
"@angular/platform-browser": "~9.1.9",
"@angular/platform-browser-dynamic": "~9.1.9",
"@angular/router": "~9.1.9",
"@ng-bootstrap/ng-bootstrap": "^6.1.0",
"bootstrap": "^4.4.0",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.901.7",
"@angular/cli": "~9.1.7",
"@angular/compiler-cli": "~9.1.9",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~3.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"TypeScript": "~3.8.3"
}
}
_
AppModuleを編集
_@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
HttpClientModule,
BrowserAnimationsModule,
CoreModule,
NgbModule
],
providers: [DataService, fakeBackendProvider, AuthService, AuthGuardService, ShoppingCartService ],
bootstrap: [AppComponent, HttpClient]
_
Angular 9の問題ですか?何か問題がありますか?
Appmoduleのbootstrap配列にHttpClientがあります。そのため、このエラーが発生しています。