title: How to fix Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: '****'
body: <p>I'm using Angular for frontend for the first time.</p>
  
  <p>In my Angular app in the <strong>user-profile.component.html</strong> there is an edit button that has a designated route for it in the <strong>app-routing.module.ts</strong> file. </p>
  
  <p>Here is my <strong>user-profile.component.html</strong></p>
  
  <pre><code>&lt;mat-spinner *ngIf="isLoading"&gt;&lt;/mat-spinner&gt;
  &lt;mat-accordion multi="true" *ngIf="posts.length &gt; 0 &amp;&amp; !isLoading"&gt;
    &lt;mat-expansion-panel *ngFor="let post of posts"&gt;
      &lt;mat-expansion-panel-header&gt;
        {{ post.title }}
      &lt;/mat-expansion-panel-header&gt;
      &lt;div class="post-image"&gt;
        &lt;img [src]="post.imagePath" [alt]="post.title"&gt;
      &lt;/div&gt;
      &lt;p&gt;{{ post.content }}&lt;/p&gt;
      &lt;mat-action-row *ngIf="userIsAuthenticated &amp;&amp; userId === post.creator"&gt;
        &lt;button mat-button color="primary" [routerLink]="['userProfileEdit', post.id]"&gt;EDIT&lt;/button&gt;
        &lt;button mat-button color="warn" (click)="onDelete(post.id)"&gt;DELETE&lt;/button&gt;
      &lt;/mat-action-row&gt;
    &lt;/mat-expansion-panel&gt;
  &lt;/mat-accordion&gt;
  &lt;mat-paginator [length]="totalPosts" [pageSize]="postsPerPage" [pageSizeOptions]="pageSizeOptions" (page)="onPageChanged($event)" *ngIf="posts.length &gt; 0"&gt;&lt;/mat-paginator&gt;
  &lt;p class="info-text mat-body-1" *ngIf="posts.length &lt;= 0 &amp;&amp; !isLoading"&gt;No posts Yet&lt;/p&gt;
  </code></pre>
  
  <p>Here in line 12 there is that <code>routerLink</code>, <code>[routerLink]="['userProfileEdit', post.id]"</code></p>
  
  <p>Which points to this route in <strong>app-routing.module.ts</strong> given below,</p>
  
  <pre><code>import { NgModule } from '@angular/core';
  import { Routes, RouterModule } from '@angular/router';
  import { PostListComponent } from './posts/post-list/post-list.component';
  import { PostCreateComponent } from './posts/post-create/post-create.component';
  import { LoginComponent } from './auth/login/login.component';
  import { SignupComponent } from './auth/signup/signup.component';
  import { AuthGuard } from './auth/auth-guard';
  import { UserProfileComponent } from './user-profile/user-profile.component';
  
  const routes: Routes = [
    {path: '', component: PostListComponent },
    {path: 'create', component: PostCreateComponent, canActivate: [AuthGuard] },
    {path: 'edit/:postId', component: PostCreateComponent, canActivate: [AuthGuard]},
    {path: 'login', component: LoginComponent},
    {path: 'signup', component: SignupComponent},
    {path: 'userProfile', component: UserProfileComponent, canActivate: [AuthGuard]},
    {path: 'userProfileEdit/:postId', component: PostCreateComponent, canActivate: [AuthGuard]}
  ];
  
  @NgModule({
    imports: [RouterModule.forRoot(routes)],
    exports: [RouterModule],
    providers: [AuthGuard]
  })
  export class AppRoutingModule { }
  </code></pre>
  
  <p>Here in line 17, there is that designated route <code>{path: 'userProfileEdit/:postId', component: PostCreateComponent, canActivate: [AuthGuard]}</code> that should correspond.</p>
  
  <p>I fixed the syntax error that I had in this line as I searched for the similar issues in SO <code>[routerLink]="['userProfileEdit', post.id]"</code>. But still it did not work. </p>
  
  <p>To mention, All other routes in that <strong>app-routing.module.ts</strong> work perfectly in all other parts of my app, no issues.</p>
  
  <p>Here is a screenshot of the error in the console log.</p>
  
  <p><a href="https://i.stack.imgur.com/5w8U0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5w8U0.png" alt="enter image description here"></a> </p>
  
  <p>Just expecting some little clue. Thank you. </p>