Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

routerLink absolute url

From angular docs :

The router link directive always treats the provided input as a delta to the current url.

For instance, if the current url is /user/(box//aux:team). Then the following link <a [routerLink]="['/user/jim']">Jim</a> will generate the link /user/(jim//aux:team).

So how do you create a link to /user/jim ?

I tried ['/user/jim', { outlets: { aux: null }}] but this isn't working.
Even if it worked it wouldn't have been a optimal solution. I'm rather looking for a way to navigate to an absolute url than cancelling possibles outlets.

EDIT:

On the same subject I have a link to the root : routerLink="/" that does just that, it redirect to the root of my application without any outlets like an absolute link. What's funny here is I don't specially want that behavior for that particular link, keeping any outlets routes was fine...

like image 202
Ghetolay Avatar asked Oct 04 '16 09:10

Ghetolay


People also ask

What is difference between routerLink and href?

Href is the basic attribute provided by Html to navigate through pages which reloads the page on click. routerLink is the attribute provided by angular to navigate to different components without reloading the page.

What is routerLink in HTML?

Linking Routes in HTMLTo add links to one of the routes, use the routerLink directive in HTML. This directive accepts an array. The first parameter is the name of the route, and the second parameter is the parameters that you want to pass with the route.

Can I use routerLink on Div?

Yes it can be attached to div tag, your route is probably wrong try add / in front of route.


1 Answers

As of August, 2018, Angular docs say:

  • If the first segment begins with /, the router will look up the route from the root of the app.
  • If the first segment begins with ./, or doesn't begin with a slash, the router will instead look in the children of the current activated route.
  • And if the first segment begins with ../, the router will go up one level.
like image 109
vulp Avatar answered Sep 23 '22 02:09

vulp