- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在我的应用程序中添加了 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)
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 } 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 { MatButtonModule } from '@angular/material/button';
import { MatMenuModule } from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { NavigationMenuComponent } from './navigation-menu/navigation-menu.component';
import { ListItemsComponent } from './list-items/list-items.component';
import { NotFoundComponent } from './not-found/not-found.component';
import { BrowserModule } from '@angular/platform-browser';
const appRoutes: Routes = [ {
path: '', //default component to display
component: ListItemsComponent
}, {
path: 'addItem', //when items added
component: NewItemFormComponent
}, {
path: 'listItems', //when items listed
component: ListItemsComponent
}, {
path: '**', //when path cannot be found
component: NotFoundComponent
}
];
@NgModule({
declarations: [
AppComponent,
NewItemFormComponent,
NavigationMenuComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
MatFormFieldModule,
MatInputModule,
MatButtonModule,
MatIconModule,
MatMenuModule,
BrowserAnimationsModule,
FormsModule,
RouterModule.forRoot(appRoutes),
ListItemsComponent,
NotFoundComponent
],
providers: [ItemService],
bootstrap: [AppComponent]
})
export class AppModule { }
ERROR in src/app/list-items/list-items.component.ts:9:14 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
Is it missing an @NgModule annotation?
9 export class ListItemsComponent implements OnInit {
~~~~~~~~~~~~~~~~~~
src/app/not-found/not-found.component.ts:8:14 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
Is it missing an @NgModule annotation?
8 export class NotFoundComponent implements OnInit {
~~~~~~~~~~~~~~~~~
最佳答案
@NgModule({
declarations: [
AppComponent,
NewItemFormComponent,
NavigationMenuComponent,
// Update this code into your code
ListItemsComponent,
NotFoundComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
MatFormFieldModule,
MatInputModule,
MatButtonModule,
MatIconModule,
MatMenuModule,
BrowserAnimationsModule,
FormsModule,
RouterModule.forRoot(appRoutes),
],
providers: [ItemService],
bootstrap: [AppComponent]
})
UPDATE your code with this snippet, you need to put your components inside declarations
关于javascript - 在我的应用程序中添加 appRoutes 后未捕获的 TypeError : Cannot read property 'id' of undefined at registerNgModuleType (core. js),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61168023/
我只是有一个更琐碎的问题。 为什么undefined == undefined 返回true,而undefined >= undefined 为false? undefined 等于 undefine
用PHP 7.2编写套接字服务器。根据Firefox 60中的“网络”选项卡,服务器的一些HTTP响应的第一行随机变为undefined undefined undefined。因此,我尝试记录套接字
在 JavaScript 中这是真的: undefined == undefined 但这是错误的: undefined <= undefined 起初我以为<=运算符包含第一个,但我猜它试图将其转换
在回答这个问题 (Difference between [Object, Object] and Array(2)) 时,我在 JavaScript 数组中遇到了一些我以前不知道的东西(具有讽刺意味的
来自https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/of , Note: thi
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
当我添加 到我的 PrimeFaces Mobile 页面,然后我在服务器日志中收到以下警告 WARNING: JSF1064: Unable to find or serve resource, u
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我是一名优秀的程序员,十分优秀!