Libin C Jacob
Libin C Jacob

Reputation: 1138

After redirect to a route it immediatly going to the previous page

It returns back to the previous page when redirect to a route using an anchor tag with [routerLink] or through the code using :

router.navigate(['/path'])

Example : If I redirect to the extractedData page from result page, it will just show the extractedData page then immediately redirecting to the result page.This is my routing module.

export const routes:Routes=[
    { path: '', redirectTo: '/home', pathMatch: 'full' },
    {path:'home', component:HomeComponent, data:{title:'Home'}},
    {path:'list',component:ListComponent, data:{title:'List'}},
    {path:'resultDetails',component:ResultDetailsComponent,data:{title:'Result Details'}},
    {path:'result',component:ResultComponent,data:{title:'Result'}},
    {path:'extractedData',component:ExtractedDataComponent,data:{title:'Extracted Data'}}
]

Upvotes: 1

Views: 701

Answers (2)

Lam Nguyen
Lam Nguyen

Reputation: 1

I encountered the same error but in another context. You can consider trying use event.preventDefault();

Upvotes: 0

vijesh
vijesh

Reputation: 1173

Try the below code

router.navigate['/extractedData']

Upvotes: 1

Related Questions