Reputation: 831
I am trying to use Angular UI router in my application. When I initialise the UI router instead of getting say, localhost:8000/#/
I get localhost:8000/#!#%2F
.
My app.js is as follows:
angular
.module('quiz',['ngMaterial',
'ngMessages',
'ngCookies',
'ngResource',
'quiz.routes'
]).config(function($resourceProvider) {
$resourceProvider.defaults.stripTrailingSlashes = false;
});
angular
.module('quiz.routes',['ui.router']);
In my quiz.routes.js I have:
(function () {
angular
.module('quiz.routes')
.config(config);
function config($urlRouterProvider,$stateProvider){
$stateProvider
.state('register',{
url: '',
templateUrl: '/static/templates/register.html'
});
}
})();
So instead of the trailing slash I get !#%2F in my URL. Why is this?
Upvotes: 1
Views: 152
Reputation: 2818
Assuming that you are using Angular version 1.6, then this is likely because of the changes made to the default hashPrefix which is now set to !
. To fix, you need to inject $locationProvider
into your module's config
block and reset the default hashPrefix back to the empty string.
$locationProvider.hashPrefix('')
This was reported as a bug here, although it turns out that it was by design and changed intentionally.
Upvotes: 3