角度版本:4
从LoginComponent
( 位于public/signin
route 登录后,我想导航到TestComponent
path public/test
。我这样做如下:this._router.navigate(['public/test'])
然后,它正确重定向但问题是它没有LoginComponent
从 DOM 中删除(尽管ngOnDestroy
确实被调用)。
值得一提的是,导航到TestComonent
使用
<a routerLink='/public/test'>Test</a>
按预期工作。
我究竟做错了什么?
app.routing.ts:
const APP_ROUTES:Routes = [
{path: 'public', loadChildren: './authentication/authentication.module#AuthenticationModule'}
];
export const APP_ROUTING:ModuleWithProviders = RouterModule.forRoot(
APP_ROUTES, {
useHash: false, enableTracing: true, initialNavigation: true});
` authentication.routing.ts(这两个组件都属于):
const routes: Routes = [
{
path: '',
children: [
{path: 'test', component: TestComponent},
{path: 'signin', component: LoginComponent},
]
}
];
export const routing = RouterModule.forChild(routes);