在带有 ui.router 的 angularjs 应用程序中,我可以执行以下操作:
$stateProvider
.state('app', {
url: '',
abstract: true,
template: '<div data-ui-view></div>'
})
.state('app.auth', {
url: '',
abstract: true,
controller: 'AuthShellController as vm',
templateUrl: 'views/auth/auth-shell-view.html'
})
.state('app.ui', {
abstract: true,
templateUrl: 'views/ui-shell-view.html',
controller: 'ShellController as vm'
和我的 angular2 应用程序路由配置:
const appRoutes:Routes = <Routes>[
{
path: '',
component: DashboardComponent,
},
{
path: 'login',
component: LoginComponent,
},
{
path: 'presentation',
children: [{
path: 'new',
component: PresentationComponent
}, {
path: ':id',
component: PresentationComponent
}]
},
];
在 angularjs 中,我可以按状态解析相同的 url,所以如果我有授权状态,我只渲染登录表单,没有标题、侧边栏。
如果我有应用程序状态,我会渲染带有页眉、页脚、侧边栏等的 shell。
Question
如何管理 angular2 路由器中的基本布局?