user1030181 user1030181 - 20 days ago 4x
AngularJS Question

How to route to Controller Index Action Method using Angular JS Routing on ng-click

I am having cancel button. When i clicked it i want to route to Index Action method of Student Controller.

How can i do that

<input type="button" class="btn btn-danger" value="Cancel" ng-click="Cancel()" />

My MVC Controller

public class TestController : Controller

// GET: Test
public ActionResult Index()
return View();



I'm assuming you are just directly wanting to go to an MVC route - If you wanted to do it directly in the View you could use:

<input type="button" class="btn btn-danger" value="Cancel" onclick="@("window.location.href='" + @Url.Action("Index", "Student") + "'");" />

Or from your Angular controller:

$scope.Cancel = function() {
    window.location = "/Student/Index";