Angular 角度-侧边栏不在登录中显示,但在仪表板中显示-角度路由
如何在登录页面中隐藏侧边栏Angular 角度-侧边栏不在登录中显示,但在仪表板中显示-角度路由,angular,angular-routing,Angular,Angular Routing,如何在登录页面中隐藏侧边栏 如何在没有侧边栏的情况下首先打开登录页面,然后在成功登录后将在Angular 4中的模板仪表板上重定向。实现这一点的最佳方法是设计一个Shell组件(由in建议),该组件将在用户登录后容纳您的视图 此壳组件的模板将包含侧杆。此外壳组件的模板还将具有一个用于内部路由的路由器出口 因此,您的路由配置将如下所示: const appRoutes: Routes = [ { path: '', component: ShellComponent,
如何在没有侧边栏的情况下首先打开登录页面,然后在成功登录后将在Angular 4中的模板仪表板上重定向。实现这一点的最佳方法是设计一个Shell组件(由in建议),该组件将在用户登录后容纳您的视图 此壳组件的模板将包含侧杆。此外壳组件的模板还将具有一个用于内部路由的
路由器出口
因此,您的路由
配置将如下所示:
const appRoutes: Routes = [
{
path: '',
component: ShellComponent,
children: [
{
path: 'dashboard',
component: DashboardComponent
},
...
{
path: 'view',
component: ViewPostComponent
},
{
path: '',
component: PlaceholderComponent
}
]
},
{
path: 'login',
component: LoginComponent
},
{
path: '',
redirectTo: '/login',
pathMatch: 'full'
}
];
Shell组件的模板:
<!--Markup for your Sidebar here-->
<router-outlet></router-outlet>
<!--This router outlet is for Components that will load through child routing-->
<router-outlet></router-outlet>
应用程序组件的模板:
<!--Markup for your Sidebar here-->
<router-outlet></router-outlet>
<!--This router outlet is for Components that will load through child routing-->
<router-outlet></router-outlet>
这里有一个供您参考的示例。共享您的代码使用一个
外壳组件
。我正在为我的angular项目使用模板,其中我需要一个没有侧栏的单独登录页面,但在我的模板中,每个页面都有侧栏,因此我想知道如何隐藏侧栏,或者如何为登录创建单独的组件