angularjs - Point [ui-router otherwise] to static page -


i have login.html different layout other sites i've put in app directory , not have state it. i'd redirect www.example/login.html if user 404.

i tried configuring ui-router inside of 1 module:

function routeconfig($urlrouterprovider, $windowprovider) {     var $window = $windowprovider.$get();     $urlrouterprovider.otherwise(function($injector, $window){         $window.location.href = '/login.html';     }); } 

but unfortunatelly got

error: $window.location undefined

how can redirect 'static page'?

your otherwise callback function of which, closure var $window = $windowprovider.$get() not same argument $window in callback function, , hence undefined.

the correct code should be:

function routeconfig($urlrouterprovider, $windowprovider) {     $urlrouterprovider.otherwise(function($injector){         var $window = $windowprovider.$get(); // put line of code inside         $window.location.href = '/login.html';     }); } 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -