Search code examples
angularjsasp.net-mvcangular-ui-routerangularjs-controller

How to redirect to an MVC view from AngularJS controller?


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();
        }
    }

Solution

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

     $window.location = '/Home/Index';