Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

178
Vistas
Using Angular's ```location.back()``` redirecting me out of my angular application

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 { }

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda