1

Assume that I have an <a routerLink="/foo"> tag, where /foo is routed to FooPageComponent, which renders content into the <router-outlet /> of AppComponent. If I Ctrl+Left Click on this link, /foo will be opened in a second tab. Does this mean that it will be an independent, second instance of my single-page application?

I know the second page uses the same server, localStorage etc., so it's not completely independent. But will it have its own instances of global objects (like the router, singleton services etc.)? Will it also run the APP_INITIALIZER code?

In general, is it good practice in case of single-page applications to let users open pages in new tabs, or is it better to stay in the same tab, and use for example popups instead of new tabs?

kol
  • 27,881
  • 12
  • 83
  • 120
  • No, they don't share their Services, they create their own instances of services. –  May 08 '20 at 11:31
  • 1
    [This](https://stackoverflow.com/questions/2829228/way-around-asp-net-session-being-shared-across-multiple-tab-windows/2839183#2839183) may be helpful if you want to prevent users from using your application on multiple tabs –  May 08 '20 at 11:34

1 Answers1

2

Answer is yes, it will create a whole new instance of your app, and rerun the APP_INITIALIZER.

And about your second question, there is no practise that is better, it depends on what you want to achieve.

Yann Armelin
  • 691
  • 4
  • 9