如何在没有参数的情况下重定向到url

时间:2018-10-03 08:12:08

标签: angular angular6 angular-routing

我需要重定向到/,并且需要传递一些参数。我希望该参数不会出现在url中。假设位于此链接中:

./Employees

,我需要返回./,以便这样做:

this.route.navigate(['./'], { queryParams: { params: 3 }, skipLocationChange: true });

问题在于重定向有效,但我阅读的网址不是./,而是./Employees。我希望该URL不是./Employees,而是成为./。有人可以帮助我吗?

1 个答案:

答案 0 :(得分:2)

我认为您的路由文件中的默认路径已重定向到员工。 例如

            {
                path: '/',
                pathMatch: 'full',
                redirectTo: 'Employees'
            },

您需要删除其中的redirectTo,并在其中添加要重定向的组件。

               {
                    path: '/',
                    component: yourComponent,
                },
相关问题