How can I open the View located at /Home/CreateItem after clicking on the Add
button? What do I need to include in my code?
$scope.Add = function() {
console.log('working');
}
This is how Index.cshtml looks like:
<script src="~/Scripts/jquery-1.9.1.min.js"></script>
<script src="~/Scripts/angular.js"></script>
<script src="~/Scripts/MyScript/Custom.js"></script>
<script src="~/Scripts/angular-animate/angular-animate.min.js"></script>
<script src="~/Scripts/angular-ui/ui-bootstrap.min.js"></script>
<script src="~/Scripts/angular-ui/ui-bootstrap-tpls.min.js"></script>
<div ng-controller="Second">
<button ng-click="Add()">Add</button>
</div>
HomeController code:
namespace MvcApplication6.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
public JsonResult GetData()
{
string data = "From controller";
return Json(data, JsonRequestBehavior.AllowGet);
}
public ActionResult CreateItem()
{
return View();
}
}
}
And here's a snippet from Controller.js:
var app = angular.module('MyApp', ['ngAnimate', 'ui.bootstrap']);
app.controller('Second', function ($scope, sharedProperties) {
$scope.Add = function() {
// How do I redirect to Home/CreateItem?
}
});