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

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 otherwise to /login , which results in the route:

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

Since it is the default route of the sigle page application , but if I want to change to a route like:

http://www.myapp.com/login

Is it possible?

Thank you.

    
asked by anonymous 28.07.2016 / 01:32

1 answer

2

Hello,

You will have to create a controller, either by javascript make redirect to the external url, something like this:

.otherwise({
    controller : function(){
       window.location.replace('http://www.myapp.com/login');
    }, 
    template : "<div></div>"
});
    
28.07.2016 / 04:15