Home > Blockchain >  How to implement routing so that when you click on a link, it doesn't open a new tab in your br
How to implement routing so that when you click on a link, it doesn't open a new tab in your br

Time:08-27

The issue is quite simple. I have a 'Home' caption created which should, when clicked on, just take you to the default page path in the browser. For example, I am on the path /dashboard, I click on the subtitle home and it should take me to the address /home so it happens, but a new browser tab is opened each time, I would like to make this transfer take place only in one browser tab. How could I do this?

routing:

  {path: 'homepage', component: HomepageComponent},

component:

  <div><a href="#" target="_blank"  routerLink="homepage" routerLinkActive="active">Home</a></div>

CodePudding user response:

Just remove the target="_blank" from a tag.

CodePudding user response:

Your problem is that you added target="_blank" to your a-Tag.

Description of target="_blank" from w3schools.

Opens the linked document in a new window or tab

Also, when you use routerLink you don't have to use the href property because you already show to another path with the Angular directive routerLink.

In the end, your code should look like this:

 <div><a  routerLink="homepage" routerLinkActive="active">Home</a></div>
  • Related