Javascript 角度-如何使用重复组件路由父/子组件?

Javascript 角度-如何使用重复组件路由父/子组件?,javascript,html,angular,Javascript,Html,Angular,我想找出最干净的方法来设置角度布线 我有一个父路由,作为一个孩子,我想在里面重复相同的组件多次(所有位置的列表)。每个位置(子)组件引用看起来都相同,只是需要传入不同的数据。(我将使用*ngFor进行此操作) 以下是我目前的想法: <router-outlet>//for the parent <router-outlet name="aux"> <ul *ngFor="let location in service.locations

我想找出最干净的方法来设置角度布线

我有一个父路由,作为一个孩子,我想在里面重复相同的组件多次(所有位置的列表)。每个位置(子)组件引用看起来都相同,只是需要传入不同的数据。(我将使用*ngFor进行此操作)

以下是我目前的想法:

<router-outlet>//for the parent 

    <router-outlet name="aux">
         <ul *ngFor="let location in service.locations"
    </router-outlet>
       //where I list out all the locations^

</router-outlet>
(我希望在初始加载时同时显示父级和子级。是否要修改该选项?^)

这是我不太了解的部分,我需要设置我的路由配置。离这儿近吗?它也会出现在我的app-routing.module.ts文件中吗

@RouteConfig([
  {path:'/', name: 'MainPath', component: MainComponent, 
   useAsDefault: true},
  {aux:'/auxRoute', name: 'AuxPath', component: SecondComponent}
])

谢谢!如果您需要澄清,请告诉我。

您的数据如何更改?你是说likes/route/item/1354吗?位置id只增加了一个,每个位置都有一个不同的名称、坐标等,我想将其显示为我主要路线上的一个表。仅每行是位置组件的一个引用。单击一个位置转到“位置/:id”
@RouteConfig([
  {path:'/', name: 'MainPath', component: MainComponent, 
   useAsDefault: true},
  {aux:'/auxRoute', name: 'AuxPath', component: SecondComponent}
])