You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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' ]"
Look for a child route named FooCmp
Look for a sibling route named FooCmp
If both exist, throw an error explaining the the developer must provide a leading / or ./ so that the link is unambiguous.
Otherwise, if one exists, use the resolved instruction.
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.
The following question might just be simply stupid but I'll give it a try:
If the leading slash is going to be "optional" for one level routing, and we can just go with [router-link]="['Cmp']" couldn't we make a shorthand syntax for it, which is a bit more intuitive and looks sth. like this [router-link]="Cmp".
I might totally miss something here, but maybe this simplifies some use cases. Otherwise, we'd need to explain upfront that there's this DSL that is way more powerful than what we actually need in this particular case, and that's why we have to stick with the brackets now.
Again, I'm just thinking out loud, wouldn't be surprised if there are 10 reasons why this can't work.
Activity
[-]feat(router): implement DSL without leading slash[/-][+]feat(router): links without a leading slash[/+]0x-r4bbit commentedon Oct 11, 2015
The following question might just be simply stupid but I'll give it a try:
If the leading slash is going to be "optional" for one level routing, and we can just go with
[router-link]="['Cmp']"couldn't we make a shorthand syntax for it, which is a bit more intuitive and looks sth. like this[router-link]="Cmp".I might totally miss something here, but maybe this simplifies some use cases. Otherwise, we'd need to explain upfront that there's this DSL that is way more powerful than what we actually need in this particular case, and that's why we have to stick with the brackets now.
Again, I'm just thinking out loud, wouldn't be surprised if there are 10 reasons why this can't work.
btford commentedon Oct 11, 2015
The RHS of the binding needs to be a JS literal, so that wouldn't work.
We shouldn't get too tricky with the sugar until we have a proper DSL.
Note that this does not make
/optional, but rather adds a new option of "link without leading slash" that has its own distinct semantics.0x-r4bbit commentedon Oct 11, 2015
Ah of course! Hey thanks for clarifying!
feat(router): add support for route links with no leading slash
angular-automatic-lock-bot commentedon Sep 7, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.