I am struggling with setting up routing in Angular 8. Here is how I am trying to do it:
'company/:id/activity'
'company/:id/contacts'
However, I am not receiving any params in the activatedRoute:
this.activateRoute.params
.subscribe(param => console.log(param) )
Any suggestions on how to resolve this issue?
Main Routing file:
{
path: 'company/:id',
children: [
{
path: '',
loadChildren: () => import('@app/features/company-view/company-view.module').then(m => m.CompanyViewModule)
}
]
}
Lazy loaded routing file:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { CompanyViewComponent } from '@app/features/company-view/company-view.component';
import { PendingChangesGuard } from '@app/shared/guards';
import { CompanyActivityComponent } from './company-activity/company-activity.component';
const routes: Routes = [
{
path: '',
component: CompanyViewComponent,
children: [
{
path: '',
redirectTo: 'view'
},
{
path: 'activity',
component: CompanyActivityComponent,
data: {
title: "Company Activity"
}
}
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class CompanyViewRoutingModule { }
If I use the following routing structure, everything works smoothly:
const routes: Routes = [
{
path: '',
component: CompanyViewComponent,
children: [
{
path: ':id/activity',
component: CompanyActivityComponent,
data: {
title: "Company Activity"
}
},
{
path: '**',
redirectTo: 'activity'
}
]
}
];
Now, I'm wondering how I can set the default routing to :id/activity
?