Saturday, March 30, 2019

ERROR Error: Uncaught (in promise): Error: Cannot match any routes.


Hi Guys ,

Today I have faced this error :

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. 

We will face this error when we enter the URL of the angular app and the URL does not have a matching route configured . To verify that check your AppModule or AppRoutingModule . 

1. check the router array :


const appRoutes:Routes =[
{path:'cust-detail',component: CustDetailComponent},
{path:'mcq',component: MCQComponent},
{path:'sign-up',component: SignUpComponent}
];


if the path is missing add to it .

2. check the import array :
imports: [
BrowserModule,
  FormsModule,
  ReactiveFormsModule,
  RouterModule.forRoot(appRoutes),
],

You need to have the RouterModule.forRoot(appRoutes) present in your application.

The full stack trace is below for your reference :


ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'test'
Error: Cannot match any routes. URL Segment: 'test'
    at ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (router.js:1384)
    at CatchSubscriber.selector (router.js:1365)
    at CatchSubscriber.push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (catchError.js:34)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:60)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:60)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:60)
    at TapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/tap.js.TapSubscriber._error (tap.js:61)
    at resolvePromise (zone.js:831)
    at resolvePromise (zone.js:788)
    at zone.js:892
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.js:3811)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
    at drainMicroTaskQueue (zone.js:601)

No comments:

Post a Comment

ec2-user@ec2 Permission denied