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

427
Vistas
angular 4: routing behavior after build --prod

I have an issue with routing when I build my app with ng build --prod. The router.config doesn't register these routes only in prod environment.

error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'myvehicle'↵Error: Cannot match any routes. URL Segment: 'myvehicle'

vehicle-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { ConfigService } from '../../core/services/config/config.service';
import { VehicleComponent } from './vehicle.component';

const vehicleRoutes: Routes = [];

ConfigService.scope('vehicle').getConfig().map(vehicle => {
  vehicleRoutes.push({
    path: vehicle['informations']['route'],
    component: VehicleComponent,
  });
});

@NgModule({
  imports: [RouterModule.forChild(vehicleRoutes)],
  exports: [RouterModule],
})
export class VehicleRoutingModule { }

export const routedComponents = [VehicleComponent];

header.component.html

<a [routerLink]="[vehicleService.getRoute(vehicle.id)]">...

The routing works when I use the following code instead of the code above:

const vehicleRoutes: Routes = [
  {
    path: "test-a",
    component: VehicleComponent,
  },{
    path: "test-b",
    component: VehicleComponent,
  }
];

I checked the path value and it's the same in the both ways as well as the console.log(vehicleRoutes) output in dev / prod environment.

ps: the path is loaded via an http request because it's based on slug set in the back office.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Please provide the base url in index.html file in base tag

Example :

<base href="https://www.w3schools.com/images/" target="_blank">
over 4 years ago · Santiago Trujillo Denunciar
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