【发布时间】:2018-10-24 10:29:23
【问题描述】:
在我的 Angular 2+ 应用程序之一中,我需要显示静态 html 文件内容。所以我把那个静态 html (helper.html) 放在 assets 文件夹中,我可以通过以下方式访问它:
http://localhost:4200/assets/helper.html
但是一旦我引入路由模块,我就会收到以下错误:
Error: Cannot match any routes. URL Segment: 'assets/static/helper.html' noMatchError
我需要在路由模块中做什么才能让这条路径正常工作?
PS:下面是我的路由模块的sn-p:
const routes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full'},
{ path: 'home', component: HomeComponent }
]
@NgModule({
imports: [ RouterModule.forRoot(routes) ],
exports: [ RouterModule ]
})
export class AppRoutingModule { }
【问题讨论】:
-
你必须像动态页面一样将它添加到 routing.module
-
如果您也可以发布您的 routing.module,这将有助于回答
-
@hana_wujira 你能告诉我如何将它添加到路由模块吗?
标签: angular angular-routing angular-router