我在我的应用程序中添加了 appRoutes,现在当我编译我的项目时,它只显示一个空白页面。我能够在 Google Chrome 上进行检查,但在对话框中出现此错误:
Uncaught TypeError: Cannot read property 'id' of undefined
at registerNgModuleType (core.js:35926)
at core.js:35944
at Array.forEach (<anonymous>)
at registerNgModuleType (core.js:35940)
at new NgModuleFactory$1 (core.js:36102)
at compileNgModuleFactory__POST_R3__ (core.js:41994)
at PlatformRef.bootstrapModule (core.js:42357)
at Module../src/main.ts (main.ts:12)
at __webpack_require__ (bootstrap:79)
at Object.0 (main.ts:13)
Run Code Online (Sandbox Code Playgroud)
这是我的 app.module.ts 代码:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
import { ItemService …Run Code Online (Sandbox Code Playgroud) 编译我的应用程序并运行时,HTML 页面显示为空白,并且不会显示该应用程序。我能够在 Google Chrome 上使用 Inspect 工具,Chrome 说record.factory 不是一个函数,页面工作正常。然而,我最近确实将我的角度版本更新到了最新版本 - 所以我不确定这是否与它有关。
这是我的 module.ts 代码,我怀疑它与导入有关,通常当我遇到应用程序不显示的问题时就是这种情况:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
import { ItemService } from './items.service';
import { NewItemFormComponent } from './new-item-form/new-item-form.component';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } …Run Code Online (Sandbox Code Playgroud)