My angular application opens at http://localhost:4200/scheduler. I have provided a button on homepage which on getting clicked redirect user to http://localhost:4200/cr?crId={{MONGODB_ID}}. The opened page has a Back button on it, on clicking on it I am calling this method.
backClicked() {
this._location.back();
}
this method is redirecting me out of my angular application. I am not able to understand what I am doing wrong.
The routing done in app-routing.module.ts is given below as
import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
import { environment } from 'src/environments/environment';
import { AuthGuard, LoginGuard } from './guard/';
import { AccessRightsGuard } from './guard/access-rights.guard';
import { UnauthorizedComponent } from './unauthorized/unauthorized.component';
export const APP_ROUTES: Routes = [
{ path: '', redirectTo: 'scheduler', pathMatch: 'full' },
{
path: 'scheduler',
canActivate: [AuthGuard, AccessRightsGuard],
loadChildren: () => import('src/app/scheduler/scheduler.module').then(m => m.SchedulerModule),
data: { rightsId: environment.accessRights['Home Page'] }
},
{
path: 'cr',
canActivate: [AuthGuard, AccessRightsGuard],
loadChildren:() => import('src/app/cr/cr.module').then(m => m.CrModule),
data: { rightsId: environment.accessRights['CrewRequiremensComponent'] }
},
{
path: '401',
component: UnauthorizedComponent,
},
{ path: '**', redirectTo: 'scheduler', pathMatch: 'full' },
The code in the routing module of scheduler module is
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { SchedulerHomeComponent } from './scheduler.component';
const SCHEDULER_ROUTES: Routes = [
{
path: '',
component: SchedulerComponent
}
];
@NgModule({
imports: [RouterModule.forChild(SCHEDULER_ROUTES)],
exports: [RouterModule]
})
export class SchedulerRoutingModule {}
The code in the routing module of cr module is
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { CrComponent } from './cr.component';
const CR: Routes = [
{
path: '',
component: CrComponent
}
];
@NgModule({
imports: [RouterModule.forChild(CR)],
exports: [RouterModule]
})
export class CrModule { }