2017-10-20 39 views
0

我有以下网址:localhost.com:1234/?param1=abc&param2=def从替换原来的URL防止Angular2路由器

Route.config = [ 
    { path: 'first', component: 'firstComponent' }, 
    { path: 'second', component: 'secondComponent' } 
] 

虽然应用程序初始化URL被替换到localhost.com:1234/#/first

我如何防止这种情况,以便我的重定向url将是localhost.com:1234/?param1=abc&param2=def#/first

+0

类似SO - https://stackoverflow.com/questions/39898656/angular2-router-keep-query-string – Asit

+0

问题在我的index.html页面添加window.history.pushState = NULL得到修复 – Asit

回答

0

当以前的路由器都不匹配时,您可以使用重定向。

{ path: '**', redirectTo: 'yourCustomComponent'}