我想将批准分离到单独的.ts文件,并导入到app.module.ts中,以使用routermodule.forroot(approutes)中的值。
const appRoutes = [
{
path: '',
component: AuthComponent,
pathMatch: 'full'
},
{
path: 'admin-portal' ,component: AdminMainComponent,
children: [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{ path: 'dashboard', component: AdminDashboardComponent },
{ path: 'user', component: AdminUserComponent },
{ path: 'role', component: AdminRoleComponent },
{ path: 'rule', component: AdminRuleComponent }
]
},
{
path: 'counter',
component: CounterComponent,
pathMath: 'full'
},
{
path: 'fetch-data',
component: FetchDataComponent,
pathMath: 'full'
},
{
path: 'login',
component: AuthComponent,
pathMath: 'full'
}
];
现在在import部分,我有routermodule的值
imports: [
BrowserModule,HttpClientModule,FormsModule,
RouterModule.forRoot(appRoutes),
BrowserAnimationsModule
],
与其把app.module.ts文件放进去,还不如把路由器组件分开,把文件分开,用app.module.ts、html、component.ts文件。
从下面的链接尝试有关动态路由的一些建议链接: