user1030181 user1030181 - 1 year ago 69
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();


Answer Source

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";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download