angular - 未捕获的错误:模块“AppModule”声明的意外值“未定义”
问题描述
收到以下错误,例如未捕获的错误:模块“AppModule”声明的意外值“未定义”。我已正确导入所有模块。但是,它仍然显示相同的错误。谁能给出解决方案?
我的代码是,
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { ProductListComponent } from './products/product-list.component';
@NgModule({
declarations: [
AppComponent,
ProductListComponent
],
imports: [
BrowserModule
],
bootstrap: [AppComponent]
})
export class AppModule { }
产品列表.component.ts
import { Component } from '@angular/core';
@Component({
selector:`pm-products`,
templateUrl:'./product-list.component.html',
styleUrls: ['./product-list.component.css']
})
export class ProductListComponent {
pageTitle: string='Product List';
}
解决方案
在 index.html 中,将选择器更改为<pm-root>
. Angularapp.component
在启动时引导您,如 中所示app.module
。在你的 app.component 中,你有你的选择器,<pm-root>
但在 index.html 中,它是<my-app>
. 不存在具有此类选择器的组件,因此您会收到错误消息。
推荐阅读
- c# - 我的界面或程序集缺少什么?
- sql - 总结sql中的表
- javascript - Wordpress onClick 功能在 li 标签中不起作用,已发布链接
- visual-studio-2017 - 我想在 VS2017 安装中添加 Nuget 包管理器。命令会是什么?
- javascript - 通过交易超级账本作曲家的新资产和其他问题
- autodesk-forge - 是否可以使用 Design Automation API 从 Revit 模型将 3d 视图导出到 ifc?
- c# - UWP XAML 如何处理 Unhandle 异常
- python - 函数在递归函数中没有正确返回?
- mysql - mysql表中匹配字母和数字的模式
- azure - 在 KUSTO ADX 中摄取失败时如何获取源数据