I am struggling to get my route to work. I am using RouterLink which does not navigate to the route. My app.routing has
const routes: Routes = [
{
path: '',
redirectTo: '/',
pathMatch: 'full'
},
{
path: '',
component: LayoutComponent,
loadChildren: () => import('./views/main/main.module').then( m => m.MainModule )
}
];
The mainModule has the following
const routes: Routes = [
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
},
{
path: 'search',
component: SearchFormComponent,
loadChildren: () => import('../../views/search/search.module').then( m => m.SearchModule )
},
{
path: '**',
redirectTo: '/home',
pathMatch: 'full'
}
];
The mainModule declares and exports LayoutComponent
In LayoutComponent.html
<a class="nav-link" [routerLink]="'/search'">
Search
</a>
But when I click on the search in the UI, the route is not going to the search component. It stays on the Home component. Please help - where am I going wrong?
path: ''and your second route ispath: 'search', Angular router is finding your first path and not going to search.