Here is my angular code
var app = angular.module('app', []);
app.controller('mainController', ['$location', '$scope', '$log', function(location, scope, log) {
log.info(location.path());
}]);
And this is my html
<div ng-controller="mainController">
<h1>Sample</h1>
<a href="#link">Go to Link</a>
<p id="link">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
Now after clicking the 'Go to link' used in my html, the url refers to localhost/angular/#!#link
and not to localhost/angular/#link
.
Infact After injecting '$location' service into the angular app any url with the fragment identifier goes to localhost/angular/#!#url
. Why does it lead to /#!#url
and not /#url
?
I am using AngularJS v1.6.1
As mentioned earlier by nivas please see your code do you have a line like this
$locationProvider.html5Mode(true)
$locationProvider.hashPrefix('!')