How to Remove Hash from URL in 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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Angular Tooltip with HTML Content Example
- Angular Get Difference Between Two Dates in Days
- How to Generate Random String in Angular?
- Angular 12 RxJS Observable with Httpclient Tutorial
- Angular 12 Httpclient Service Request Example
- How to Create Service in Angular 12?
- How to use Bootstrap Modal in Angular 12?
- Angular 12 Multiple Image Upload with Preview Example
- File Uploading in Angular 12 Tutorial
- How to Add Bootstrap in Angular 8 | Install Bootstrap 4 in Angular 8
- AngularJS Filter Change Date Format in Controller Example
- AngularJS Ajax Autocomplete Using Typeahead in PHP Example