In my application I have multiple components and one is Products and that is in the app.module and my product.module.ts (StartProductsComponent if it shows it) I have the following lines:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DesarrolloTecnologicoInnovacionComponent } from './DesarrolloTecnologicoInnovacion/desarrollo-tecnologico-innovacion.component';
import { InicioProductosComponent } from './inicio-productos/inicio-productos.component';
const routes: Routes = [
{
path: 'inicio-productos',
component: InicioProductosComponent
}
,
{
path: 'DesarrolloTecnologicoInnovacion',
component: DesarrolloTecnologicoInnovacionComponent
}
];
@NgModule({
declarations: [
],
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class ProductosRoutingModule { }
In the DesarrolloTecnologicoInnovacion module, it was generated in this way:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DesarrolloTecnologicoInnovacionModule } from './desarrollo-tecnologico-innovacion.module';
const routes: Routes = [
{
path: 'DesarrolloTecnologicoInnovacion',
component: DesarrolloTecnologicoInnovacionModule
},
{ path: '**', redirectTo: '/productos', pathMatch: 'full' }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class DesarrolloTecnologicoInnovacionRoutingModule { }
but when navigating and putting the route in the browser:
http://localhost:4200/DevelopmentTechnologyInnovation
It doesn't show me the component that is located in this folder.. TechnologicalInnovationDevelopment
My knowledge in angular is little, so I don't know if I'm doing something wrong.
Your routes array should contain a list of objects with 2 properties, path, which defines the URL for the route, and component, which defines the component that Angular should use for that route. That said, you have an error in your DesarrolloTecnologicoInnovacionRoutingModule, you are assigning DesarrolloTecnologicoInnovacionModule instead of DesarrolloTecnologicoInnovacionComponent