Abel Chalier
Abel Chalier

Reputation: 639

angular add slash before hash in url

When i try to add a hash in the url like :

<a href="#whatever">whatever</a>

or

window.location.hash = 'whatever';

it appends a '/' before the hash world

=> www.mysite.com/#whatever

but it should be

=> www.mysite.com#whatever

I know this is caused by angular, but i can find a way to prevent it.
Is there a way to prevent this behaviour ?

Thanks

Upvotes: 8

Views: 6854

Answers (2)

Alexei - check Codidact
Alexei - check Codidact

Reputation: 23078

For those new to AngularJS world, configuration should be defined when declaring the module. E.g.:

var someModule = angular.module("someModule", [/* dependent modules come here */],
    function ($locationProvider) {

        $locationProvider.html5Mode({
            enabled: true
        });
});

Upvotes: 2

Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85545

Turn on html5 mode:

.config(function($locationProvider) {
  $locationProvider.html5Mode(true);
})

See more detail here.

Upvotes: 9

Related Questions