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...
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.
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.
Yes it can be attached to div tag, your route is probably wrong try add / in front of route.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With