pap*_*tis 4 angular2-routing angular
我正在创建一个类似于应用程序的仪表板.我想在Angular(2+)中实现以下布局计划:
等等...
所以基本上我想做的是完全替换<body>某些(子)路由的内容.
这对我来说不好:角度为2的不同页面的多个布局,因为我不想将/(root)重定向到像/ home这样的任何地方.
这个也不适合:如何在Angular2中切换布局
任何帮助都会很棒!
Ram*_*ami 10
您可以使用子路径解决您的问题.
请参阅https://angular-multi-layout-example.stackblitz.io/上的工作演示或在https://stackblitz.com/edit/angular-multi-layout-example进行编辑
设置如下路线
const appRoutes: Routes = [
//Site routes goes here
{
path: '',
component: SiteLayoutComponent,
children: [
{ path: '', component: HomeComponent, pathMatch: 'full'},
{ path: 'about', component: AboutComponent }
]
},
// App routes goes here here
{
path: '',
component: AppLayoutComponent,
children: [
{ path: 'dashboard', component: DashboardComponent },
{ path: 'profile', component: ProfileComponent }
]
},
//no layout routes
{ path: 'login', component: LoginComponent},
{ path: 'register', component: RegisterComponent },
// otherwise redirect to home
{ path: '**', redirectTo: '' }
];
export const routing = RouterModule.forRoot(appRoutes);
Run Code Online (Sandbox Code Playgroud)
推荐参考:http://www.tech-coder.com/2017/01/multiple-master-pages-in-angular2-and.html
| 归档时间: |
|
| 查看次数: |
3717 次 |
| 最近记录: |