简体   繁体   English

Angular Visual Studio删除嵌套组件

[英]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 line ( import { Component } from ./your-component ) 导入行( import { Component } from ./your-component
  • component in your NgModule imports ( @NgModule({ imports: [ ... ] }) ) NgModule导入中的组件( @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.

相关问题 Visual Studio中的Angular 6组件声明编译器错误 - Angular 6 Component Declaration compiler error in Visual Studio 无法在Visual Studio Code中创建角度组件 - Cannot create angular component in Visual Studio Code Angular 10 Visual Studio Code 中 HTML 组件中的“未找到...的定义” - Angular 10 “No definition found for …” in HTML component in Visual Studio Code 如何在 Visual Studio 中使用默认 angular 项目导入组件 - how to import a component using the default angular project in Visual Studio 在 Visual Studio IDE 中创建/生成新 Angular 组件的简单方法? - Easy way to create / generate new Angular component in Visual Studio IDE? 在Visual Studio 2015中重复使用和在Angular2组件中传递参数 - Reusing & Parameters Passing In Angular2 Component, in Visual Studio 2015 如何从 Angular 组件标记重定向到它在 Visual Studio 中的定义? - How to redirect from an Angular component markup to its definition in Visual Studio? 无法在Visual Studio 2015的Angular 1组件中运行Angular 2组件 - Can't run an Angular 2 component inside an Angular 1 component in Visual Studio 2015 角度删除动态组件 - Angular Delete dynamic component Angular 6 中的嵌套组件 - Nested Component in Angular 6
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM