With the help of this article, the problem was solved.
For accessing the params in parent route, we need to use activeRoute.parent.params
instead of activeRoute.params
this.activatedRoute.parent.params.subscribe(
(params) =>
{
console.log(params.accountid);
});
Also from this stackoverflow question , a solution to make all params (including parent route params) available to child routes was found.
This is done by including a configuration object with the paramsInheritanceStrategy set to always where we import RouterModule
eg :
import {RouterModule, ExtraOptions} from "@angular/router";
export const routingConfiguration: ExtraOptions = {
paramsInheritanceStrategy: 'always'
};
export const Routing = RouterModule.forRoot(routes, routingConfiguration);
Now we can access both parent and child route params using activeRoute.params