我有一个登录页面,它将显示用户(默认情况下)和“注册”组件,这是一组允许他们注册的输入字段。
对于返回用户,我希望他们按原样查看登录页面,然后单击“登录”并将注册组件替换为登录组件。我不希望 URL 改变,它应该保持 '/'。
对于 ui-router 我可以做嵌套状态,但不确定 Angular2 的路由器是否支持它?
应用程序.ts
@Component({
selector: 'app',
template: '
*snip*
<router-outlet></router-outlet>
*snip*
',
directives: [Footer, ROUTER_DIRECTIVES]
})
@RouteConfig([
{ path: '/...', name: 'Landing', component: LandingComponent, useAsDefault: true },
{ path: '/about', name 'About', component: AboutComponent }
]);
登陆.ts
@Component({
selector: 'landing',
template: '
<body>
<div>
<router-outlet></router-outlet>
</div>
</body>',
directives: [ROUTER_DIRECTIVES]
})
@RouteConfig([
{ path: '/', name: 'RegisterForm', component: RegisterForm, useAsDefault: true },
{ path: '/login', name: 'LoginForm', component: LoginForm },
])
着陆组件的路径是否需要不同?