Angular 将零部件作为子零部件以角度加载
我正在使用angular 6并尝试将组件作为子组件导入 我有一个组件可以通过路由到Angular 将零部件作为子零部件以角度加载,angular,routing,Angular,Routing,我正在使用angular 6并尝试将组件作为子组件导入 我有一个组件可以通过路由到'/register'来访问,该组件加载注册组件,我还有另一个组件使用'/services'加载服务组件,并且我在多个组件中同时使用这两个路由 现在我的问题是,我想加载ServicesComponent作为SigUpComponent的子组件,即类似于'/register/services'(一种嵌套路由),条件是我的两条路由都是单独定义的。有什么方法可以做到这一点,而不是将第三条路由重新定义为'/register
'/register'
来访问,该组件加载注册组件
,我还有另一个组件使用'/services'
加载服务组件
,并且我在多个组件中同时使用这两个路由
现在我的问题是,我想加载
ServicesComponent
作为SigUpComponent
的子组件,即类似于'/register/services'
(一种嵌套路由),条件是我的两条路由都是单独定义的。有什么方法可以做到这一点,而不是将第三条路由重新定义为'/register/services'
,将ServicesComponent
定义为SigUpComponent
的子组件,您可以像这样使用子路由:
const parentModuleRoutes: Routes = [
{
path: 'parent-component', //<---- parent component declared here
component: PetParentComponent,
children: [ //<---- child components declared here
{
path:'child-one',
component: ChildOneComponent
},
{
path:'child-two',
component: ChildTwoComponent
},
{
path:'child-three',
component: ChildThreeComponent
},
{
path:'child-four',
component: ChildFourComponent
},
]
}
];
const parentModuleRoutes:Routes=[
{
路径:'父组件',//我不知道你到底在找什么,但你试过这个吗?你在angular网站上查过了吗?就在那里