Skip to content

Angular routing keeps redirecting me to the home page #26

Open

Description

@monikap90

I am facing a issues with the routing in Angular .It keeps redirecting me to the home page even though I am entering a valid url (http://localhost:4200/services)
This is my code:

app.routing.module

const routes: Routes = [
{path: 'services', loadChildren: () => import('./routes/services/services.module').then(m => m.ServicesModule)},
{ path: '', loadChildren: () => import('./routes/home/home.module').then(m => m.HomeModule) },
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: '**', pathMatch: 'full', redirectTo: ''},
];

home-routing.module

const routes: Routes = [{ path: '', component: HomeComponent, children: [
{ path: '', component: HomeStartingViewComponent },
{ path: '', component: MeetUsComponent },
{ path: '', component: ServiceItemsComponent },
{ path: '', component: TitleComponent },
{path:'', component:CaseStudyComponent},
{path: '', component:BenefitsComponent},
{path:'', component:PartnersComponent}],
}]

services-rouiting.module

const routes: Routes = [{ path: '', component: ServicesComponent, children: [
{path:'', component:TitleComponent}
] }];

Activity

  1. kartik1211 commented on Jan 7, 2026

    @kartik1211

    Cause 1: Two ‘’ routes at the top level

    { path: '', loadChildren: () => import('./routes/home/home.module').then(m => m.HomeModule) },
    { path: '', redirectTo: 'home', pathMatch: 'full' },

    Angular matches routes top to bottom.
    The first path: '' already matches every URL, including /services.

    Cause 2:
    Multiple empty child routes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions