[英]Angular Visual Studio Delete Nested Component
I'm very new to Angular, coming from a Web Forms background. 我是Angular的新手,来自Web Forms背景。 I Set up an Angular project in Visual Studio and going through tutorials.
我在Visual Studio中设置了一个Angular项目并进行了教程。 I'm trying to delete a component.
我正在尝试删除一个组件。 I've removed all references to it in app.module.ts and app.component.ts and deleted the .js, .ts files for the component.
我已经在app.module.ts和app.component.ts中删除了对它的所有引用,并删除了该组件的.js,.ts文件。 When I run the project the console error states my deleted component is not a known element.
当我运行项目时,控制台错误指出我删除的组件不是已知元素。 How do you get rid of a component using Visual Studio?
如何使用Visual Studio摆脱组件? I also removed some html in the template and the browser still renders it.
我还删除了模板中的一些html,浏览器仍将其呈现。
Welcome to StackOverflow ! 欢迎使用StackOverflow!
This happens because your app stills try to register your component in your module. 发生这种情况是因为您的应用仍然在尝试在模块中注册组件。
To fix that, open your app.module.ts
, and remove all occurences of component you want to delete. 要解决此问题,请打开
app.module.ts
,然后删除所有要删除的组件。
You should remove : 您应该删除:
import { Component } from ./your-component
) import { Component } from ./your-component
) @NgModule({ imports: [ ... ] })
) @NgModule({ imports: [ ... ] })
) Make sure that in the app.module.ts you removed the import statement AND the name of the component in the declaration section of @NgModule. 确保在app.module.ts卸下的导入语句,然后在@NgModule的声明部分组件的名称。
When you say you removed the files, I'm assuming you removed the folder. 当您说删除文件时,我假设您删除了该文件夹。 Check that as well.
也检查一下。
Other than that, you can go to the "Error list" and see what's lines are causing the error and remove them. 除此之外,您可以转到“错误列表”,查看引起错误的行是什么并将其删除。
Side note: I also came from a Web Forms background and after I learned Angular a few months ago and I fell in love with it! 旁注:我也是来自Web Forms的背景,几个月前我学习了Angular之后,我爱上了它! Web Forms never again.
Web窗体再也不会。 The productivity difference for me was astronomical.
对我来说,生产力差异是天文数字。 Keep up!
赶上! Angular is not easy at first but when you get used to it you will build web applications in a really productive manner.
Angular一开始并不容易,但是当您习惯了它时,您将以一种非常有效的方式构建Web应用程序。 If you're starting a project, I recommend you to check out PrimeNG if you haven't done so.
如果您正在启动一个项目,我建议您检查PrimeNG(如果尚未执行的话)。 They have really good components and it's easy to implement.
它们具有非常好的组件,并且易于实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.