Reputation: 332
I am using AngularJS routing and I used many tricks, but the '#' sign always comes in URL.
Refer below Example/Code that I Used but it is not removing # sign from the URL.
angular.module('mod', []).
config(['$routeProvider', '**$locationProvider'**,
function($routeProvider, **$locationProvider**) {
$routeProvider.
when('/first', {
templateUrl: 'first.html',
controller: 'firstCtrl'
});
$locationProvider.html5Mode(true);
}]);
Does any one have solution for this? Please share it.
Upvotes: 2
Views: 1049
Reputation: 1640
I've came up with the same issue and found the solution on the Docs.
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
and
<head>
<base href="/">
...
</head>
If you configure $location to use html5Mode (history.pushState), you need to specify the base URL for the application with a tag or configure $locationProvider to not require a base tag by passing a definition object with requireBase:false to $locationProvider.html5Mode():
We've done the wrong function call. Try this and it will work. You can check the docs too.
Upvotes: 1
Reputation: 2862
there are either of things u can do it work
you need to specify the base URL for the application with a If your root of your application is different than the url (for example /my-app, then use that as your base).
<head>
<meta charset="utf-8">
<base href="">
</head>
or you can configure
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
Upvotes: 2