相关疑难解决方法(0)

在Angular中,我如何直接导航到延迟加载模块中的路径?

我想有两个顶级路径用于登录和注册.

我宁愿没有做auth/log-inauth/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

routing angular2-routing angular2-router angular

14
推荐指数
2
解决办法
3694
查看次数

加载同一模块的多个路径 - 延迟加载

我在一个模块中有多个组件。我想根据路由路径显示组件。对于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 中做了哪些更改以显示这些组件。

angular angular-router

9
推荐指数
1
解决办法
3252
查看次数