Angular的redirectTo不更新地址栏中的路径

问题描述 投票:0回答:1

我已根据我的角度路由配置成功重定向:

  {
    path: 'mypath',
    redirectTo: 'myotherpath',
    pathMatch: 'full',
  },
  {
    path: 'mypath',
    children: [
        {
            path: ':id',
            component: MyComponent,
        },
    ]
  }

[当您点击'mypath'而不传递id参数时,您将被重定向到'myotherpath'。太好了,一切正常,但是即使它已加载“ myotherpath”页面,它在地址栏中仍显示旧地址(例如http://localhost/mypath)。

这是预期的行为吗?我现在有一个页面,其中地址栏与显示的内容不同步。如何配置它,以便地址栏在重定向后立即更新?

编辑

[确认-'myotherpath'已经具有用于路由配置的自己的条目,可以直接导航到。如果“ mypath”无效(从某种意义上说,没有提供ID),这更多的是重定向。

我已根据我的角度路由配置成功重定向:{path:'mypath',redirectTo:'myotherpath',pathMatch:'full',},{path:'mypath',子代:[...

routing angular8 address-bar
1个回答
0
投票

“ path”只是地址栏中的名称,

© www.soinside.com 2019 - 2024. All rights reserved.