angular - “路由器插座”不是角度 6 中的已知元素
问题描述
使用 angular-cli 重新安装 angular6 时出现以下错误。
未捕获的错误:模板解析错误:'router-outlet' 不是已知元素: 1. 如果'router-outlet' 是 Angular 组件,则验证它是否是该模块的一部分。
我遵循了本指南:https ://medium.com/@meemo_86/good-article-beeman-490eaf1399a
然后我跟进了对该文章的评论,该文章说使用<router-outlet></router-outlet>
而不是<ng-content></ng-content>
.
我做了这些更正,然后我阅读了https://angular.io/tutorial/toh-pt5,并按照那里的说明进行操作。
所以现在我有了一个AppRoutingModule
,我在 app.module.ts 中导入了那个模块,我还在其中 const 路由并添加RouterModule.forRoot(appRoutes)
到导入中。
但我不能让这个错误消失。我究竟做错了什么?当我添加<router-outler></router-outlet>
我layout.component.htm
的 时,应用程序会中断。我也在这里搜索了这个主题并尝试了一些更改,但似乎没有任何效果。
完整的源代码在这里:
解决方案
我看到你RouterModule
在 UIModule 的导入中丢失了
@NgModule({
imports: [
CommonModule,
RouterModule
],
declarations: [LayoutComponent, HeaderComponent, FooterComponent],
exports: [LayoutComponent]
})
export class UiModule { }
推荐阅读
- python - 如何在 PyQT5 中随窗口大小改变显示大小?
- javascript - (jQuery) 将变量内容克隆到 Div
- nlp - 如何使用 conllu python 库保存编辑的 .conllu 文件
- java - 将对象分配给对象
- javascript - Javascript Regex 测试字符串是否在分隔行上只有数字
- android - 使用意图时如何将DatabaseReference传递给android中的类?
- android - 如何限制android播放器并行播放多个媒体文件?
- json - 使用 Perl 模块 LWP::Authen::OAuth2 创建 Google Team Drive
- javascript - 使用 CSHTML MVC 中的模型创建具有预定义列的动态表
- java - 我无法重新打开 Eclipse 项目