Angular 添加具有角度的新组件时出错

Angular 添加具有角度的新组件时出错,angular,Angular,我从Angular开始,但在添加新组件时遇到问题: 我已经在Angular中启动了一个新项目,带有ng new toto无错误,然后我添加了一个新组件,带有ng generate component menu无错误,我删除了我的app.component.html中的所有内容,并使用添加了MenuComponent app.module.ts menu.component.ts app.component.html 我的问题是为什么这个简单的东西不起作用 我的错误 错误:模板分析错误: “Men

我从Angular开始,但在添加新组件时遇到问题:

我已经在Angular中启动了一个新项目,带有
ng new toto
无错误,然后我添加了一个新组件,带有
ng generate component menu
无错误,我删除了我的
app.component.html
中的所有内容,并使用
添加了
MenuComponent

app.module.ts

menu.component.ts

app.component.html

我的问题是为什么这个简单的东西不起作用

我的错误

错误:模板分析错误:
“MenuComponent”不是已知元素:
1.如果“MenuComponent”是角度组件,则验证它是否是此模块的一部分。
2.若要允许任何元素,请将“无错误模式”添加到此组件的“@NgModule.schemas”。(“[错误->]
“”:ng:///AppModule/AppComponent。html@0:0

提前感谢您的帮助

我确信
菜单组件
选择器应该是不同的

使用您在
菜单.component.ts中的
选择器,而不是使用组件名称本身。大概

<app-menu> </app-menu>

我确信
菜单组件的
选择器应该不同

使用您在
菜单.component.ts中的
选择器,而不是使用组件名称本身。大概

<app-menu> </app-menu>


你能发布
菜单的代码吗。component
?我更新了我的帖子,我添加了menu.component.t你能发布
菜单的代码吗?component
?我更新了我的帖子,我添加了menu.component.t确定它与
一起工作,为什么?它不应该与一起工作?好的,它与
一起工作,为什么?它不应该和你一起工作?
<MenuComponent></MenuComponent>
Angular CLI: 6.0.0
Node: 10.0.0
OS: linux x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0
 Error: Template parse errors:
'MenuComponent' is not a known element:
1. If 'MenuComponent' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("[ERROR ->]<MenuComponent></MenuComponent>
"): ng:///AppModule/AppComponent.html@0:0
<app-menu> </app-menu>