In my app-routing.modules.ts I have the following script:
import { NgModule } from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {SearchComponent} from './search/search/search.component';
import {RegisterComponent} from './register/register.component';
import {LoginComponent} from './login/login.component';
const routes: Routes = [
{ path: 'search', component: SearchComponent },
{ path: 'register', component: RegisterComponent },
{ path: 'login', component: LoginComponent }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
The HTML of my LoginComponent contains <a href="#">Top</a>
. If the user clicks on that link, he will be redirected to the root page. I have also tried it with <a href="login/#">Top</a>
but the same page will be reloaded.
What is the reason for that? I just want the user to jump on the top of the page.