1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Angular routing with dynamic prefix

Discussão em 'Angular' iniciado por Heathcliff, Setembro 11, 2024.

  1. Heathcliff

    Heathcliff Guest

    I have a success page that I want to redirect to after certain actions. Currently my url would just be localhost:4200/success after redirecting but I would like my url to append the /success to whatever path I am currently being redirected from because my succes page is generic and receives its data from the redirecting component.

    Example: while writing a review my url would be localhost:4200/review, after successfully posting a review I wish to redirect to my success page while turning the url into localhost:4200/review/success

    How can I dynamically prefix a path in Angular ?

    My lazy loaded routing-module would look something like this:

    {
    path: 'review',
    loadChildren: () => import('./review/review.module').then(m => m.ReviewModule)
    },
    {
    path: 'order',
    loadChildren: () => import('./order/order.module').then(m => m.OrderModule)
    },{
    path: 'succes',
    loadChildren: () => import('./succes/succes.module').then(m => m.SuccesModule)
    },


    SuccesModule:

    const succesRoutes: Routes = [
    { path: '', component: SuccesComponent },


    ];

    Continue reading...

Compartilhe esta Página