Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么RoutingModule在我的angular应用程序中不工作?_Angular_Angular5_Angular6_Angular Routing - Fatal编程技术网

为什么RoutingModule在我的angular应用程序中不工作?

为什么RoutingModule在我的angular应用程序中不工作?,angular,angular5,angular6,angular-routing,Angular,Angular5,Angular6,Angular Routing,编辑:请注意,在尝试将我的应用程序模块拆分为功能模块以进行延迟加载之前,一切正常 因此,我尝试将我的应用程序模块拆分为其他功能模块,以便在我的angular应用程序中使用延迟加载 但我有个错误 未捕获错误:模板分析错误:无法绑定到“routerLink” 因为它不是“h4”的已知属性。class=col-3> ]routerLink=/profile/{{castra.id}}/public> {{castra.name} :ng:///CastraModule/CastrasComponent

编辑:请注意,在尝试将我的应用程序模块拆分为功能模块以进行延迟加载之前,一切正常

因此,我尝试将我的应用程序模块拆分为其他功能模块,以便在我的angular应用程序中使用延迟加载

但我有个错误

未捕获错误:模板分析错误:无法绑定到“routerLink” 因为它不是“h4”的已知属性。class=col-3> ]routerLink=/profile/{{castra.id}}/public> {{castra.name} :ng:///CastraModule/CastrasComponent。html@18:85 在syntaxError compiler.js:215 在TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse compiler.js:14687 在JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler.\u parseTemplate compiler.js:22687 在JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler.\u compileTemplate compiler.js:22674 在compiler.js:22617 每小时一次 在JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler.\u compileComponents compiler.js:22617 在compiler.js:22527 在Object.then compiler.js:206 在JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents compiler.js:22526

这是我的功能模块

(Imports)

@NgModule({
declarations: [
CastrasComponent,
ProfileComponent,
PublicComponent,
MenuComponent,
ReservationComponent
],
imports: [
CommonModule,
TestRoutingModule
]
})
export class CastraModule { }
我的测试路由模块

(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 { }

测试模块导入到应用程序模块中,那么问题出在哪里?

您可能需要什么?把它包起来

编辑


您需要将RouterModule添加到使用RouterOutlet或routerLink等路由器指令的每个模块的导入:[]

您可以尝试使用RouterModule.forRootTestRoutes而不是RouterModule.forChildTestRoutes它在我的路由器文件中工作

在尝试将我的应用程序模块拆分为功能模块以便延迟加载之前,请详细说明您具体在做什么?我正在将我的应用程序模块拆分为功能模块以提高性能您必须确保这些模块导入RouterModule或任何其他导出RouterModule的模块是的,我在所有模块中导入了RouterModule,它可以正常工作,谢谢
<h4><a routerLink="menu">Part1</a></h4>