我想有两个顶级路径用于登录和注册.
我宁愿没有做auth/log-in和auth/register.
但是,auth组件位于一个单独的模块中,这很好,因为除非特别要求,否则不应加载它.
export const routes: Route[] = [
{ path: 'log-in', loadChildren: './auth-module/auth.module#AuthModule'},
{ path: 'register', loadChildren: './auth-module/auth.module#AuthModule'}
];
Run Code Online (Sandbox Code Playgroud)
我如何指定何时定义我希望log-in路径转到延迟加载的AuthModule 内部路径的log-in路径,以及转到延迟加载模块内部路径的路径?registerregister
我在一个模块中有多个组件。我想根据路由路径显示组件。对于http://localhost:4200/account我想显示帐户组件。对于http://localhost:4200/setting我想显示设置组件 ..etc
app.routing.module.ts
{
path: 'account',
loadChildren: './modules/settings/settings.module#SettingsModule',
},
{
path: 'settings',
loadChildren:'./modules/settings/settings.module#SettingsModule',
},
Run Code Online (Sandbox Code Playgroud)
settings.routing.module.ts
export const routes: Routes = [
{
path: 'account',
component: accountComponent
},
{
path: 'account/edit',
component: accountEditComponent
},
{
path: 'settings',
component: settingsComponent
},
{
path: 'settings/edit',
component: settingsEditComponent
}
];
Run Code Online (Sandbox Code Playgroud)
我在 settings.routing.module.ts 中做了哪些更改以显示这些组件。