Posted inTechnology / AngularJS / Tips and Tricks

Remove Hashtag From URL in AngularJS

Remove Hashtag From URL in AngularJS

Today, We want to share with you Remove Hashtag From URL in AngularJS.
In this post we will show you Pretty URLs in AngularJS: Removing the #, hear for Removing Hashbang from URL in AngularJs Route we will give you demo and example for implement.
In this post, we will learn about Removing “#” From URL in AngularJS with an example.

How to remove # from URL in AngularJS?

If you work on AngularJS any SPA’s or web application using angular multiple pages or route then you notice most useful one thing. If you check any link click on any hyper links it creates like as bellow simple generated URI:

http://live24u.com/#
http://live24u.com/#/students
http://live24u.com/#/teachers

We stands always put “#” symbols will be add there, So when we live this any application or web application then it should remove or delete “#” Special Symbols from Your Angular Routing URL, because it creates issue when we some share link on Social media facebook, Twitter, Linkdin or etc.

http://live24u.com/
http://live24u.com/students
http://live24u.com/teachers

Enabling Base URL (Relative URLs)


If We are using Latest New version of an Angularjs, then We can simple directly write this Scripts to enable Your html5mode.

$locationProvider.html5Mode(true);

But You can delete or remove simple Way to easily using angular “$locationProvider.html5Mode(true);”. You can do it like as bellow simple example We did, So Create sure you have to simple first add HTML base tag on your HTML head tag sections like as bellow scripts:

....//Some Title//External Links...//Devloped By : Pakainfo.com

Simple Angular JS Route

var liveapp = angular.module('live-App',['ngRoute']);
liveapp.config(['$routeProvider','$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider.
when('/', {
templateUrl: 'templates/students.html',
controller: 'StudentCtrl'
}).
when('/teachers', {
templateUrl: 'templates/teachers.html',
controller: 'TeacherCtrl'
}).
otherwise({
redirectTo: '/'
});

//It's Most Imp.
$locationProvider.html5Mode(true);
}]);

Remove # from URL AngularJS : Conclusion

This is the Very Useful way to Delete or remove Hash From Application URL and get a SEO based pretty URL.

We hope you get an idea about Remove Hashtag From The Routing URL – $locationProvider
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like Face Book Page.

We hope This Post can help you…….Good Luck!.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype