Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i want to redirect from an express function to an angularjs partial to load with the controller of that view.

app.js -->nodejs

function(req, res, next) {
    console.log(req.session);
    if(req.session.user/* && req.session.user.role === role*/)
      next();
    else
      res.redirect("/#/login");
  }

app.js -->angularjs

app.config(function($routeProvider){
$routeProvider
.when("/create", {
    templateUrl : "/users/usersCreate",
    controller : "users"
})
.when("/delete", {
    templateUrl : "/users/usersDelete",
    controller : "users"
})
.when("/login", {
    templateUrl : "/sessions/sessionsCreate",
    controller : "sessionsCtr"
})

.otherwise({ reditrectTo : "/" });

})

its not working :( help

share|improve this question

1 Answer

You cannot redirect Angular.js when requesting a partial. Angular.js is issuing an AJAX call and that won't follow a redirect response in the same way a browser does.

This other answer provides guidance on how to go about it:

http://stackoverflow.com/a/15261558/446681

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.