角组件没有被破坏 [英] Angular component are not getting destroyed

查看:93
本文介绍了角组件没有被破坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在有角度的应用程序中,每次我路由到新页面时,我先前页面的组件都会保留在内存中。它并没有被破坏,当我返回该页面时,它创建了一个新实例。



应用程序不是通过有角度的CLI创建的。这是一个自定义的构建应用程序,使用的是角度网站上提供的webpack配置。实际上,我正在改进现有的angular应用程序以及为隔离问题而创建的此演示应用程序的性能。



Github

解决方案

实际上,我尝试在生产模式下运行上述Github应用程序,此问题已解决。但是生产应用程序中的实际问题仍然存在。但这与其他事情有关。我将为此发布一个新问题。


In angular application, every time I route to a new page, my earlier page's component is staying in memory. It's not getting destroyed and when I route back to that page it creates a new instance.

Application is not created through angular CLI. It's a custom build application using the webpack configuration provided on angular website. Actually, I am doing performance improvement of the existing angular application and this demo app I created for isolation of issue.

Github https://github.com/bytesofdhiren/angular-memory-issue

Basically, every time I route to home or register page, the application creates a new instance of the register component and home component. It's not destroying the earlier created component.

解决方案

Actually, I tried running the above Github application in production mode and the issue got resolved. But the actual issue in my production application still exists. But that is related to something else. I will post a new question for that.

这篇关于角组件没有被破坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆