I have 2 differents paths for the same component, and they use resolve data:
//app.routing:
const APP_ROUTES: Routes = [
{
path: '',
canActivate: [LoggedInGuard],
children: [
{path: '', redirectTo: '/path1', pathMatch: 'full'},
{path: 'path1', loadChildren: 'app/myModule.module#MyModuleModule'},
{path: 'path2', loadChildren: 'app/myModule.module#MyModuleModule'}
]
},
{path: '**', redirectTo: ''}
];
export const routing = RouterModule.forRoot(APP_ROUTES);
In myModule.routing:
const MY_MODULE_ROUTES: Routes = [
{path: '', component: MyModule2Component, resolve: {data: MyModule2Resolver}}
];
export const myModuleRouting = RouterModule.forChild(MY_MODULE_ROUTES);
All this works fine.
Now I would like to control routing from MyModule2Resolver:
@Injectable()
export class MyModule2Resolver implements Resolve<any[]> {
constructor(private activatedRoute: ActivatedRoute, private router: Router) {}
resolve(): Promise<any> {
//Different action depending on path1 or path2 but
// I have not this info in activatedRoute or router
}
}
Is it possible?