Search code examples
angularroutesangular-routing

url with query params redirecting to / in angular


In my application I am using lazy loading. Here is the app.module.ts

const appRoutes: Routes = [
    {
        path: "your-app",
        canActivate: [AuthGuard],
        loadChildren: "app/components/your-app/your-app.module#YourAppModule"
    },
    {
        path: "my-app",
        canActivate: [AuthGuard],
        loadChildren: "app/components/my-app/my-app.module#MyAppModule"
    },
    {
        path: "**",
        redirectTo: "/"
    }
];

and my child module

export const routes: Routes = [
    {
        path: "",
        component: MyAppComponent
    }
];

and when I hit http://localhost:4200/#/my-app?myParam=test

it redirect me to http://localhost:4200/#/

is there any thing missing?


Solution

  • Just for the others if somebody else would be looking for solution in case of similar issues - check your guard as it can block your access to the path. It was also an issue here (see: comments to the question).