Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
741 views
in Technique[技术] by (71.8m points)

routes - Angular Router always get back to Main Page

I've got a problem with Angular Router (Angular 11). That's my routing below:

{path: '', redirectTo: '/zaloguj', pathMatch: 'full'}
{path: 'zaloguj', component: LoginComponent}
{path: 'orzeczenia', component: ApiComponent}
{path: 'orzeczenia/:id', component: ShowDataComponent}
{path: 'kontakt', component: ContactComponent}
{path: 'konto', component: DashboardComponent}
{path: '**', component: PageNotFoundComponent}

I created the function (below) in one of my component:

showVerdict(): any {
this.router.navigate(['/kontakt']);

}

When I use this function, Angular goes to the Kontakt Route (ContactComponent), but after maybe 1 sec, redirects to MainPage. I changed the route to for example "konto", etc. however, the problem still occurs. Please help me!

question from:https://stackoverflow.com/questions/65912191/angular-router-always-get-back-to-main-page

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I resolved the problem. It was trivial. I added the click event to an "a link", but I forgot to remove href="#"... Now, everything is fine.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...