How to Remove Hash from URL in Angular?

By Hardik Savani August 16, 2021 Category : Angular


Here, i will show you how to works how to remove hash from url in angular. This article will give you simple example of angular remove hash prefix. We will use angular remove hash from url. you will learn angular routing remove hash (#) on url.

I will give you one solution how to remove hash from url in angular application. we will use useHash make true. you can use this example with in angular 6, angular 7, angular 8, angular 9, angular 10, angular 11 and angular 12 version app.

Let's see both solution:


imports: [


RouterModule.forRoot(routes, { useHash: true }) // remove second argument


Remove useHash: true from router modules, By default it's false. let's add add bellow:


import { NgModule } from '@angular/core';

import { RouterModule, Routes } from '@angular/router';

import { HomeComponent } from './home/home.component';

import { UserComponent } from './user/user.component';

const routes: Routes = [

{ path: 'home', component: HomeComponent },

{ path: 'user', component: UserComponent },



imports: [RouterModule.forRoot(routes)],

exports: [RouterModule]


export class AppRoutingModule { }

you can try it now...

Tags :