尝试在模块内创建多个路由 (Angular)

Trying to create multiple routes inside module (Angular)

我是 Angular 的新手,正在尝试在模块内创建一些路由。我定义了模块路由并按预期工作,即在我的主页上,我可以单击此模块路由 'localhost:4000/module_name',它将呈现该视图。

在这个模块中我有很多组件,我想做的是设置最终看起来像 'localhost:4000/module_name/component_name' 的路由。但出于某种原因,我一直找不到页面。

目前看起来像这样:

testModule (dir):
   testModule-routing.module.ts
   testModule.component.html
   testModule.component.ts
   testModule.module.ts
   testComponent (dir)
      testComponent.component.html
      testComponent.component.ts
testModule-routing.module.ts:

const routes: Routes = [
  {
    path: 'test_module',
    component: testModuleComponent,
    children: [
      { path: 'test_component', component: testComponentComponent },
    ]
  }
];

testModule.component.html:

<div>
   <a routerLink="test_component">test</a>
</div>

我认为这应该假设有效?但我一直找不到页面。任何帮助将不胜感激。

也许可以尝试将 routerLink 放在方括号中。

<div>
   <a [routerLink]="test_component">test</a>
</div>

我是 Angular 的新手,但我就是这样做的。