编辑:请注意,在尝试将我的应用程序模块划分为功能模块以延迟加载之前,一切都很好。
因此,我试图将我的应用程序模块分成其他功能模块,这样我就可以在我的角度应用程序中使用延迟加载,
但我犯了个错误
“未明错误:模板解析错误:无法绑定到'routerLink‘,因为它不是'h4’的已知属性。(“ng:///CastraModule/CastrasComponent.html@18:85”-3“>]routerLink=”/profile/{castra.id}}/public“>{castra.name} "):TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (compiler.js:215) at syntaxError (compiler.js:14687 )) JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate (compiler.js:22687) at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate (compiler.js:22674) compiler.js:22617 at Set.forEach () at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler.JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:22526) _compileComponents (compiler.js:22617)在compiler.js:22527 at Object.then (compiler.js:206)
这是我的特色模块
(Imports)
@NgModule({
declarations: [
CastrasComponent,
ProfileComponent,
PublicComponent,
MenuComponent,
ReservationComponent
],
imports: [
CommonModule,
TestRoutingModule
]
})
export class CastraModule { }我的TestRoutingModule
(Imports)
const testRoutes: Routes = [
{path: 'test', component: TestComponent},
{
path: 'profile/:id', component: ProfileComponent,
children: [
{path: '', redirectTo: '/profile/:id/public', pathMatch: 'full'},
{path: 'public', component: PublicComponent},
{path: 'menu', component: MenuComponent},
{path: 'reservation', component: ReservationComponent},
]
}
]
@NgModule({
imports: [
RouterModule.forChild(TestRoutes)
],
exports: [RouterModule]
})
export class TestRoutingModule { }测试模块是在应用程序模块中导入的,那么问题是什么?
发布于 2018-10-07 17:44:44
你可能需要?将它包装在<a> and </a>中
<h4><a routerLink="menu">Part1</a></h4>编辑
您需要将使用路由器指令(如imports: []或routerLink )的每个模块的RouterModule添加到RouterOutlet。
发布于 2018-10-07 19:04:05
您可以尝试使用RouterModule.forRoot(TestRoutes)而不是RouterModule.forChild(TestRoutes),它可以在我的路由器文件中工作。
https://stackoverflow.com/questions/52691162
复制相似问题