Angular "relativeTo" in "routerLink"-directive

When navigating inside my module that is mounted in an unknown path (e.g. /app/mod1/{module}) I use the following method: this._router.navigate(['create'], { relativeTo: this._route.parent });.

This will navigate to /app/mod1/create. How do I accomplish this using the routerLink directive? Right now I get the following results (assuming right now I'm in /app/mod1/items/123):

  • routerLink="create" --> /app/mod1/items/123/create
  • routerLink="/create" --> /create
  • routerLink="./create" --> ./app/mod1/items/123/create

How to I achieve /app1/mod1/create independent of the current route inside my module using only the directive?

1 answer

  • answered 2020-11-24 10:41 Bojan Kogoj

    Would this work?