I am trying to change the routing of an existing app. The app has many concepts I don't have under my belt like lazy loading and advanced routing techniques, so I hope someone can help me.
I have the following hierarchy:
components(folder)
operador (component)
criar (component)
atualizar (component)
operador.module.routing.ts
Operador.module.routing.ts is like this
const routes: Routes = [
{path: '', component: OperadorComponent,
children: [
{path: 'criar', component: CriarComponent}
]
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class OperadorRoutingModule {
}
When I have a router like like this in the operador component it won't navigate to the criar component.
<a routerLink="criar" >
I got the following erro on Chrome:
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'dash/operadores/criar' Error: Cannot match any routes. URL Segment: 'dash/operadores/criar' at ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError
Edited to include more code.
I have the following file on the root of the app, app-routing.module.ts.
import { HomeComponent } from './components/home/home.component';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const appRoutes: Routes = [
{path: '', loadChildren: 'src/app/components/entrar-
app/entrarapp.module#EntrarModule'},
{path: 'dash', component: HomeComponent},
];
@NgModule({
imports:[RouterModule.forRoot(appRoutes)],
exports: [RouterModule]
})
export class AppRoutingModule{}