1

I need to redirect to another MVC view from a controller in AngularJS. Which services do I need to inject? I tried $window service and it does not work. Do I have to use $http service? Does anyone have any example for this? Thank you!

AngularJS controller:

$window.location('/Home/Index');

MVC controller:

 public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }
    }
1

2 Answers 2

3

location is not an method over window object. Simply assign URL to location property

 $window.location = '/Home/Index';
Sign up to request clarification or add additional context in comments.

Comments

3

You should try with full path in location

var url = "http://" + $window.location.host + "/Home/Index";
$window.location.href = url;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.