简体   繁体   English

关于这个 angular 问题有什么建议吗? Mosh 教程对我不起作用?

[英]Any advice on this angular problem? Mosh tutorial not working for me?

watching https://youtu.be/k5E2AVpwsko and made it to the 1:35:00 roughly time of adding the courses part.观看https://youtu.be/k5E2AVpwsko并在添加课程部分的大致时间到了 1:35:00。 I ge the following error.我得到以下错误。 Failed to compile.编译失败。

../src/app/app.component.html:2:1 - error NG8001: 'courses' is not a known element: ../src/app/app.component.html:2:1 - 错误 NG8001:“课程”不是已知元素:

  1. If 'courses' is an Angular component, then verify that it is part of this module.如果“课程”是 Angular 组件,则验证它是该模块的一部分。
  2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.要允许任何元素,请将“NO_ERRORS_SCHEMA”添加到该组件的“@NgModule.schemas”中。

2 2


../src/app/app.component.ts:5:16
  5   templateUrl: './app.component.html',
                   ~~~~~~~~~~~~~~~~~~~~~~
  Error occurs in the template of component AppComponent.

What am i missing? I tried debugging, but nothing. Any help is appreciated.

You haven't declared courses component as part of app module.您尚未将课程组件声明为应用程序模块的一部分。 In declarations array, you need to give it.在声明数组中,您需要提供它。 Also you could try the ng commands like ng g component courses from the app module directory in terminal, instead of creating it manually which automatically adds it to app module.您也可以从终端的应用程序模块目录中尝试 ng g 组件课程等 ng 命令,而不是手动创建它,然后自动将其添加到应用程序模块。

You should delete the app component and use ng generate component courses.It will automatically add the component to your app module.您应该删除应用程序组件并使用 ng generate 组件课程。它会自动将该组件添加到您的应用程序模块中。 It is easy and handy.它既简单又方便。 You can also watch documentation of angular component which will be much helpful for your development您还可以观看 angular 组件的文档,这对您的开发很有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM