Remove Hashtag From URL in AngularJS

AngularJS Technology Tips and Tricks

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!.


Related FAQ

Here are some more FAQ related to this Article:

  1.   laravel 6 Retrieve data using jQuery Ajax
  2.   yards in a mile Online conversion Formula
  3.   Class 'PhpParser\Parser\Php7' not found
  4.   Angular 6 - User Registration and Login Example & Tutorial
  5.   Laravel 6 Multiple File Uploading Dropzone js Example
  6.   Http JSONP Service using Angular Example
  7.   PHP Laravel 6 Multiple Database Connections Tutorial
  8.   how to check empty array in laravel controller?
  9.   Removing # hash from URL in AngularJS
  10.   Jquery Responsive Fancybox Popup Example

Leave a Reply

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