How to remove hash(#) from url in angular

Many times you might see a hash(#) symbol embedded somewhere in your URL in an angular application such as http://localhost:4200/#/auth.
This hash although is added by the routing module of the application, it is not added manually. Though it causes no problem but you might need to remove it.

Solution
In the root routing module file(app.routing.module.ts) or the appropriate routing file, look for the below line

RouterModule.forRoot(routes, {useHash : true})

and change the useHash argument to false or remove it altogether.
Thus, the modified code will be either

RouterModule.forRoot(routes, {useHash : false})

or

RouterModule.forRoot(routes)

Hopefully this will remove the hash symbol from the URL.

Click the clap below if this article helped.

1

Leave a Reply

Mark Your Impression

  Subscribe  
Notify of
Close Menu

Never Miss an article !

Get the new post delivered straight into your inbox, enter your email and hit the button

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

codippa will use the information you provide on this form to be in touch with you and to provide updates and marketing.