简体   繁体   English

如何防止新选项卡中的Angular渲染组件

[英]How to prevent Angular rendering component in new tab

I have an Angular component that should be rendered only once, on the first screen of the app, and not every time I open a tab. 我有一个Angular组件,应该只在应用程序的第一个屏幕上呈现一次,而不是每次打开选项卡时都呈现一次。

Using localStorage to mark the component as active is a bit problematic since one can close the browser and it will be hard to track that. 使用localStorage将组件标记为活动状态会有些问题,因为可以关闭浏览器并且很难跟踪它。

如果使用* ngIf隐藏组件,则每次打开选项卡时都会使用角度渲染组件,这是很合逻辑的,请尝试使用: [hidden]="!expression"而不是*ngIf="expression"

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

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