I would like simply to redirect from / to /shop each one somebody types the root. I tried with $state.go in the controller, but it didn't do the trick. I would like to do it without $urlRouterProvider.otherwise (as there are also urls without routing in my web). Any ideas how to do that? Thanks in advance!
app.config(function($stateProvider, $urlRouterProvider) {
$stateProvider.state('root', {
url: "/",
controller: {
function() {
$state.go('shop')
}
}
}).state('shop', {
url: "/shop",
controller: 'myCtrl',
templateUrl: "/shopcontent.jsp"
})
});
$state.current.nameto get the current state name. In this case it will give you 'root'.(function() { if ($state.current.name == 'root') { $state.go('shop'); } });