我有一个角度路由的问题,如果一个带有参数的URL从应用程序外部请求,应用程序就会失败。
如果您从应用程序导航到http://localhost:4200/clients,或者只是在地址栏中键入它,则此路径可以工作。
如果您从应用程序导航到http://localhost:4200/clients/20,而如果在地址栏中输入,则不工作,则使用。
备注:在控制台中,它从第二级路由(http://localhost:4200/clients/assets/vendor/jquery/jquery.js而不是http://localhost:4200/assets/vendor/jquery/jquery.js)请求css和javascript文件。
有什么帮助吗?
发布于 2017-12-14 14:37:13
修复是通过在路由中启用哈希来完成的。
在app.module.ts中
RouterModule.forRoot(
[
{ path: 'Home', component: HomeComponent },
{ path: 'ImportOperations', component: ImportOperationComponent },
{ path: 'ImportData/:Id', component: ImportRawDataComponent },
{ path: 'rules/:Id', component: RulesComponent },
{ path: 'newrule', component: RulesComponent },
{ path: 'rules', component: RulesListComponent },
{ path: 'search', component: SearchComponent },
{ path: 'editresult/:Id', component: EditSearchComponent }
]
,{useHash: true}), https://stackoverflow.com/questions/47795910
复制相似问题