angular - routerLink 绝对 url

标签 angular angular2-routing

来自 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).

那么如何创建到/user/jim 的链接呢? ?

我试过了 ['/user/jim', { outlets: { aux: null }}]但这不起作用。
即使可行,也不是最佳解决方案。我宁愿寻找一种导航到绝对 URL 的方法,也不愿取消可能 导出。

编辑:

关于同一主题,我有一个指向根目录的链接:routerLink="/"就是这样,它重定向到我的应用程序的根目录,没有像绝对链接这样的任何导出。有趣的是,我并不是特别想要那个特定链接的行为,保留任何导出路线都很好......

最佳答案

截至 2018 年 8 月,Angular docs说:

  • 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.

关于angular - routerLink 绝对 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39848860/

相关文章:

Angular 2 + ng 测试 : 'X' is not a known component

javascript - Angular2 路由。 url末尾的斜线

javascript - Angular2路由中,URL改变了但内容没有更新

angular2 ng-template 在一个单独的文件中

css - 更改所选文本的样式/格式 - Angular

performance - 如何衡量 Ionic 3 应用程序的性能?

function - Angular 2 : TypeError 'this.' is undefined

html - 右键单击在新选项卡中打开在 div 标签内的 routerlink 上不可用

angular - 在同一路由器 socket 中加载嵌套路由

javascript - 在 Angular 2 中加载子组件时如何隐藏父组件