0

Here: https://stackblitz.com/edit/partehoras?file=src/app/app.module.ts

When I add App Roting like I do it in my VS Code local project without any problem

In package.json

enter image description here

enter image description here

I get this error: "Error in src/app/app.module.ts (5:34) Cannot find module './app-routing.module' or its corresponding type declarations."

Any idea, please?

Thanks

kintela
  • 1,283
  • 1
  • 14
  • 32

1 Answers1

0

You already have RouterModule.forRoot([]) imported in the app module, I am assuming you want to move to a separate file, if so, you need to create a file in the same folder as the app module with the name app-routing.module.ts and add the following code

import { RouterModule, Routes } from '@angular/router';
import { ListadoEmpleadosComponent } from './empleados/listado-empleados/listado-empleados.component';
import { NgModule } from '@angular/core';

export const routes: Routes = [
  { path: 'empleados', component: ListadoEmpleadosComponent },
  { path: '', redirectTo: 'empleados', pathMatch: 'full' },
  { path: '**', redirectTo: 'empleados', pathMatch: 'full' },
];

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

P.S. if you generate an angular app using the angular CLI you will get a prompt to create app routing module which will create the file automatically.

Mr. Stash
  • 2,940
  • 3
  • 10
  • 24