Reputation: 2205
I have the following route:
$stateProvider
.state('admin', {
url: '/admin/',
templateUrl: 'app/admin/admin.html',
controller: 'AdminCtrl',
controllerAs: 'admin',
authenticate: 'admin'
});
Everything works as excepted but the thing is if I go to /myapp/admin instead of /myapp/admin/ it redirects me to /, how can I go to my state 'admin' even if i go to admin/ or /admin/.
Can someone explain me what I'm doing wrong?
Upvotes: 1
Views: 87
Reputation: 387
Try this it must work
app.config(function($urlRouterProvider){
$urlRouterProvider.rule(function($injector, $location) {
var path = $location.path();
var hasTrailingSlash = path[path.length-1] === '/';
if(hasTrailingSlash) {
//if last charcter is a slash, return the same url without the slash
var newPath = path.substr(0, path.length - 1);
return newPath;
}
});
}
Upvotes: 2