Angular 5 routing cannot match url segment

423 Views Asked by At

We have an app with the following URL.

 http://localhost:8080/myapp/#/route1

My routing configuration for the same is as follows

export const routeConfig = [
{
 path: 'myapp',
 children: [
  {
    path: 'route1',
    loadChildren: 'app/route1/route1.module#Route1Module',
  }
]
}];

When I try to access the URL I get the following error -

Error: Cannot match any routes. URL Segment: 'myapp/'
Error: Cannot match any routes. URL Segment: 'route1'
at t.noMatchError (main.bundle.js:1)
at e.selector (main.bundle.js:1)
at e.error (polyfills.bundle.js:1)
at e._error (polyfills.bundle.js:1)
at e.error (polyfills.bundle.js:1)

What is the right configuration for routing in this scenario ? What should be the base href ?

1

There are 1 best solutions below

0
glqdlt On

Is there a routing module that routes route1 children within the route1 module? Your setup has lazy loaded the 'mayapp / route1 / ...' URL routing into the route1 module. This means that the solution you want should be handled in route1 module. If so, you need to configure url routing in 'route1 module'.