sheko
sheko

Reputation: 556

Router not working When i need to open another page

I have an angular app that i need to root to next page by opening it in a new tab with

<button class="button"> <a target="_blank" routerLink="/goToNext" 
           routerLinkActive="active current" > {{ 'items' | translate }} 
</a></button>

I configured the component here in app.moduls.ts

const appRoutes: Routes = [ 
   { path: 'goToNext', component: NextComponent },
]

RouterModule.forRoot(
  appRoutes,
  { enableTracing: true } 
)

But current when i click the button browser link changes and the next component is not shown it's like a reload of the main site page only ???

Upvotes: 0

Views: 218

Answers (1)

Tzimpo
Tzimpo

Reputation: 1009

This seems a little confused.

Opening your application in another window or tab will require your entire application to be re-bootstrapped, and then for your router to... pick up that url, convert it into a route, and load the appropriate component.

This is exactly what will happen if you just use a link instead. In fact, that's all that's happening.

The point of the router is to swap components in and out of your router-outlet, which is something that's been bootstrapped and exists within the confines of your running application and isn't shared across multiple windows.

Upvotes: 1

Related Questions