Remove Hashtag From The Routing URL
Whenever we write URL of an angular application , a hashtag ie (#) always appear after the application root folder
For Example: –
https://www.conflate.com /tutorial/angularjs/#/emp_details/0
In this Post, we will explain you how to remove hashtag from the routing URL. LIVE DEMO & GET WP THEME
In earlier application code, you have noticed that whenever you run the application through some URL, a hashtag, i.e /#/, will appear in the URL just after the application folder name, which looks ugly.
So, let’s remove this hashtag from the URL and make you URL more beautiful and comfortable to read.
For this, you need to do two changes in the application.
1. Configure $locationProvider service in the application module.
2. Add a base tag in head section the application.
Configure $locationProvider
$locationProvider is used to to configure the application module and tell it how to store deep linking path of the application.
It uses html5Mode() method with true as parameter to remove hashtag, i.e /#/, from the URL of the application.In Angular, the
$location
service parses the URL in the address bar and makes changes to your application and vice versa.Configuring $locationProvider will remove the hashtag from the application URL but, application will not load correctly. To resolve this, we will have to add a base tag in the head section of the index page.
The base tag has one property, href. Href contains the URL path up to the application root folder.
For Example:-
Let suppose a URL,
https://www.conflate.com/tutorial/angularjs/#/emp_details/0
Here, angularjs is the root folder of the application.
Then, we will write base tag as: –
<base href="https://www.conflate.com /tutorial/angularjs/"/>
After it, the application will load properly and the application URL will look something like
https://www.conflate.com /tutorial/angularjs/emp_details/0
You can refer how to remove hashtag from below video:
Thanks Guys,hope you got the concept for this little but very important trick. Apply it in your application and share your feedback with us.Also If you have more such tricks and solution feel free to share.
nice information.keep posting good stuff :) all the best
ReplyDeleteHey,Thanks Aniruddha. Keep following and keep sharing.
DeleteReally good one. Very helpful.
DeleteThanks dear.Keep following and help others.
DeleteThank you for sharing such an informative article. I really hope I can see other interesting posts. Keep up the good work!
ReplyDeleteThanks a lot.I will surely keep posting such posts.If you need any more help and want to to have post on it feel free to contact us.
DeleteBut when reload the page https://www.conflate.com /tutorial/angularjs/emp_details/0
ReplyDeleteit will give error like Cannot GET /tutorial/angularjs/emp_details/0 . How to solve this . I am using laravel as backend .
But when reload the page https://www.conflate.com /tutorial/angularjs/emp_details/0
ReplyDeleteit will give error like Cannot GET /tutorial/angularjs/emp_details/0 . How to solve this . I am using laravel as backend .
This is just example,we have used here for better understanding.
DeleteExcellent ! I am truly impressed that there is so much about this subject that has been revealed and you did it so nicely.
ReplyDeleteAngularjs developer
Thanks Emma for your inspiring words. Please share and keep following.
DeleteNice Blog, Keep sharing your ideas and information.I would like more information about this, because it is very nice...Thanks for sharing. Thanks a lot
ReplyDeleteAnika Digital Media
seo services in UK
web design development company in UK
Great Article Cyber Security Projects projects for cse Networking Security Projects JavaScript Training in Chennai JavaScript Training in Chennai The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training
ReplyDeleteThanks for sharing the great content. It will helps a lot.
ReplyDeleteThanks Again.
Web Development Company India
Thanks for your marvelous posting! I really enjoyed reading it. you're a great author. I will be sure to bookmark your blog and will come back very soon..God bless uou HDPE Pipe Fittings
ReplyDeleteServices offered by SEO Services in London
ReplyDeleteSeo Analysis Hub Facebook
Seo Analysis Hub Pinterest
Seo Analysis Hub Twitter
Seo Analysis Hub Linkedin
Seo Analysis Hub Medium Blog
this is a great article about vapes in kampala
ReplyDeleteI really appreciate your post, and you explain each and every point very well. Thanks for sharing this information.
ReplyDeleteangularjs training in chennai
I really appreciate your post, and you explain each and every point very well. Thanks for sharing this information.
ReplyDeleteangularjs training in chennai