X Tutup
Skip to content

feat(router): links without a leading slash #4623

@btford

Description

@btford

@matsko and @IgorMinar and I talked about this in the past.

Currently, we require all router-links to have their first element to start with either / or with ./:

<a [router-link]="[ '/MyCmp' ]"></a>

For apps with one level of routing, the distinction between routing to a child and routing to a sibling is irrelevant. It'd be nice to omit the leading / or ./:

<a [router-link]="[ 'MyCmp' ]"></a>

We should change the behavior of generating the instruction (and subsequent link) to match a link DSL array with no leading ./ or / as follows:

For [router-link]="[ 'FooCmp' ]"

  1. Look for a child route named FooCmp
  2. Look for a sibling route named FooCmp
  3. If both exist, throw an error explaining the the developer must provide a leading / or ./ so that the link is unambiguous.
  4. Otherwise, if one exists, use the resolved instruction.
  5. If neither route matches, we throw an error telling the developer so.

This will help address some of the developer confusion WRT routes that's come up in our hackathons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort1: hoursfeatureLabel used to distinguish feature request from other issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup