Remove Hashtag(#) from URL in AngularJS

Remove Hashtag(#) from URL in AngularJS

Now i am going to tell how to remove hashtag(#) from the URL. it is very easy to remove hash sign from URL.

-> Add $locationProvider service in the angular application.

-> Add a basetag in head section of angular application

Inject $locationProvider

var app = angular.module('MyApp', []);
app.config(function ($routeProvider, $locationProvider) {
    // don't forget to set HTM5 mode true
    $locationProvider.html5Mode(true);
    $routeProvider
    .when('/', {
        templateUrl : 'partials/home.html',
     })
     .when('/contact', {
        templateUrl : 'partials/contact.html',
      });
});

Don t forgot to set html5Mode to true.

Add Basetag

Added basetag in head section because application does not load correctly while $locationProvider

<head>
    <base href=" "/>
</head>

after the change

http://www.neukanndo.com/#/contact

0 Comments

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed

>