Reputation: 2902
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();
}
}
Upvotes: 1
Views: 2172
Reputation: 101
You should try with full path in location
var url = "http://" + $window.location.host + "/Home/Index";
$window.location.href = url;
Upvotes: 3
Reputation: 136144
location is not an method over window
object. Simply assign URL to location property
$window.location = '/Home/Index';
Upvotes: 3