Angular routes: prefix matching

Discussão em 'Angular' iniciado por Web-Intern, Junho 9, 2025.

  1. Web-Intern

    Web-Intern Guest

    I am reading documentation on the Angular routing and created a simple test:


    const routes: Route[] =
    [
    { path: '', redirectTo: '/home', pathMatch: 'full' },
    { path: 'home', pathMatch: 'prefix', component: HomeComponent },
    // { path: '**', component: PageNotFoundComponent },
    ];


    To my understanding the path like "/home/12345" should match the second route. The path is a prefix for this URL... But this does on happen:
    ​

    [​IMG]

    The behavior is like it has not mapped any component on the router outlet. The big header on the page comes from the upper component. If I uncomment the third route ("**"), this path would go to the PageNotFoundComponent.

    What am I doing wrong or where is my misunderstanding? Why my 2-path variant is not working?

    Continue reading...

Compartilhe esta Página