When I am trying to reload the url, the page refreshes to the default navigation. I want to stop that and reload the same url again. This is how my routing module looks like:
const routes: Routes = [
{
path: 'store', component: AppComponent, children:
[
{ path: 'public', component: HomeComponent, data: { defaultSelectedTab: 0 } },
{ path: 'public/softwares', component: HomeComponent, data: { selectedValue: 'softwares', defaultSelectedTab: 0 } },
{ path: 'public/softwares/:id', component: SoftwareDetailsComponent },
{ path: '', redirectTo: "public", pathMatch: 'full' },
]
},
{
path: '**', component: EmptyComponent
}
];
@NgModule({
imports: [RouterModule.forRoot(routes, { useHash: true, onSameUrlNavigation: 'reload'})],
exports: [RouterModule]
})
export class AppRoutingModule { }
I tried to do something like this where each of the independent path become a children of the previous one:
{
path: 'public',
component: HomeComponent,
data: { defaultSelectedTab: 0 },
children: [
{
path: 'softwares',
component: HomeComponent,
data: { selectedValue: 'softwares', defaultSelectedTab: 0 },
children: [
{
path: ':id',
component: SoftwareDetailsComponent
}
]
}
]
},
{ path: '', redirectTo: "public", pathMatch: 'full' },
But then this one doesn't even route it to the right component. I was trying to take a clue from the answer with the max votes. If in case it helps the router-outlet is specified in AppComponent. Still I am not sure what am I doing wrong. Any help is much appreciated.