empty path (/) not redirecting to dashboard in angular 17

47 views Asked by At

I am using ASP.NET Boilerplate with angular. Recently I updated angular version from 11 to 17. In 11 when I entered http://localhost:4200/ it redirects to http://localhost:4200/app/main/dashboard. But after updating to 17 it do not redirects to http://localhost:4200/app/main/dashboard. It only loads http://localhost:4200/ and shows a blank page. Even after login it do not redirect to http://localhost:4200/app/main/dashboard by default if there is no redirectUrl. Though I have defined root routing in RootRouteModule, but these routes are not triggered. Below is the root route declaration for both version 11 and version 17.

RootRouteModule in Version 11:

`

import { NgModule } from '@angular/core';
import { Routes, RouterModule, Router, NavigationEnd } from '@angular/router';
import { AppUiCustomizationService } from '@shared/common/ui/app-ui-customization.service';

const routes: Routes = [
    // { path: '', redirectTo: '/app/main/dashboard', pathMatch: 'full' },
    { path: '', redirectTo: '/app/main/welcome-page', pathMatch: 'full' },
    {
        path: 'account',
        loadChildren: () => import('account/account.module').then(m => m.AccountModule), //Lazy     load account module
        data: { preload: true }
    }
];

@NgModule({
    imports: [RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' })],
    exports: [RouterModule],
    providers: []
})

`

RootRouteModule in Version 17:

`

import { NgModule } from '@angular/core';
import { Routes, RouterModule, Router, NavigationEnd } from '@angular/router';
import { AppUiCustomizationService } from '@shared/common/ui/app-ui-customization.service';

const routes: Routes = [
    // { path: '', redirectTo: '/app/main/dashboard', pathMatch: 'full' },
    { path: '', redirectTo: '/app/main/welcome-page', pathMatch: 'full' },
    {
        path: 'account',
        loadChildren: () => import('account/account.module').then(m => m.AccountModule), //Lazy     load account module
        data: { preload: true }
    }
];

@NgModule({
    imports: [RouterModule.forRoot(routes, {})],
    exports: [RouterModule],
    providers: []
})

`

I thought the AppRouteGuard was not triggering that's why it was not working. I tried changing the AppRouteGuard. But none of my attempts worked. I don't know what is the issue here after updating angular 17.

Kindly help me fixing this issue...

0

There are 0 answers