角版本:4角路由器,旧组件在DOM停留
从LoginComponent
(位于public/signin
航线登录后,我想导航到TestComponent
路径public/test
我。这样做如下:this._router.navigate(['public/test'])
然后,它正确地重定向,但问题是,它并没有从DOM删除LoginComponent
(虽然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);
我有同样的确切的问题,你有没有想出如何解决呢? thx。 –
你有一个正常的Angular设置吗?或者它是一个混合应用程序? – Ben
我有一个正常的设置... –