Paka Information

Remove Hashtag From URL in AngularJS

1.22K 0

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:

Also Read :  Quickly Tips To Improve SEO with Increase Google Page Ranking

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)

<base href="/YOUR_FOLDER_NAME/Index/">   

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:

Also Read :  Top 10 Advanced MySQL Interview Questions Answers

<head>
	<base href="/"> 
	....
	//Some Title
	//External Links...
	//Devloped By : Pakainfo.com
</head>

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.

Also Read :  How to Quickly Index New Post In Google Search

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

Leave A Reply

Your email address will not be published.