ItSolutionStuff.com

How to Remove Hash from URL in Angular?

By Hardik Savani • May 2, 2024
Angular

Hi,

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, angular 12, angular 13, angular 14, angular 15, angular 16 and angular 17 version app.

Let's see both solution:

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:

src/app/app-routing.module.ts

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 },

];

@NgModule({

imports: [RouterModule.forRoot(routes)],

exports: [RouterModule]

})

export class AppRoutingModule { }

you can try it now...

Tags: Angular
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Angular Tooltip with HTML Content Example

Read Now →

Angular Get Difference Between Two Dates in Days

Read Now →

How to Generate Random String in Angular?

Read Now →

Angular 12 RxJS Observable with Httpclient Tutorial

Read Now →

Angular 12 Httpclient Service Request Example

Read Now →

How to Create Service in Angular 12?

Read Now →

How to use Bootstrap Modal in Angular 12?

Read Now →

Angular 12 Multiple Image Upload with Preview Example

Read Now →

File Uploading in Angular 12 Tutorial

Read Now →

How to Add Bootstrap in Angular 8 | Install Bootstrap 4 in Angular 8

Read Now →

AngularJS Filter Change Date Format in Controller Example

Read Now →

AngularJS Ajax Autocomplete Using Typeahead in PHP Example

Read Now →