Angular version: 4
After logging in LoginComponent(located in the route public/signin, I want to go to TestComponentthe path public/test. I do it like this: this._router.navigate(['public/test'])
Then it redirects correctly, but the problem is that it does not delete LoginComponentfrom the DOM (although the call ngOnDestroyinvokes the call).
It is worth noting that the switch to TestComonentusing
<a routerLink='/public/test'>Test</a>works as expected.
What am I doing wrong?
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 (where both of these components belong):
const routes: Routes = [
{
path: '',
children: [
{path: 'test', component: TestComponent},
{path: 'signin', component: LoginComponent},
]
}
];
export const routing = RouterModule.forChild(routes);
source
share