routerLink absolute url

前端 未结 7 1583
梦谈多话
梦谈多话 2020-12-30 20:54

From angular docs :

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

For instance, if the curre

相关标签:
7条回答
  • 2020-12-30 21:55

    As of May, 2020, there was no working answer to the initial question which can be used with the builtin [routerLink], so here it comes.

    In your question, the ['/user/jim', { outlets: { aux: null }}] idea was good, but you have to specify the primary outlet explicitly:

    <a [routerLink]="['/', { outlets: { primary: 'user/jim', aux: null } }]">
      This will be a link to '/user/jim', without any route in the aux path
    </a>
    

    (As far as I know, there is no way currently to use [routerLink] with an absolute url without cancelling possible outlets.)

    You can follow the same logic for your EDIT. If you don't change the aux outlet, but set the primary explicitly to empty (the root), you can navigate to the root and keep the current outlet(s):

    [routerLink]="['/', { outlets: { primary: '' } }]"
    
    0 讨论(0)
提交回复
热议问题