Otherwise with redirectTo to another url that is not part of the Single page application

Asked

Viewed 127 times

0

For example, on the routes below:

app.config(function($routeProvider){
    $routeProvider.when('/dashboard', {
        templateUrl: "../views/dashboard.html",
        controller : "dashboardCtrl"
    }).when('/cadastro', {
        templateUrl: "../views/signin.html",
        controller : "signInCtrl"
    }).otherwise({
        redirectTo : '/login'
    });
})

I use the otherwise for /login, which has as consequence the route:

http://www.myapp.com/rotaAtual/#/login

Since it is the standard route of sigle page application, but in case I want to switch to a route like:

http://www.myapp.com/login

it is possible?

Thank you.

1 answer

2


Hello,

You’ll have to create a controller, either by javascript redirect to the external url, something like that:

.otherwise({
    controller : function(){
       window.location.replace('http://www.myapp.com/login');
    }, 
    template : "<div></div>"
});
  • Thanks, it worked as well as I wanted. But, one thing, it only works with the template statement?

  • Dude, I ask you the same question above, why did you use the template? What does it mean in this situation? Links?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.