i am learning mvc
i downloaded code tried to implement same but in my application on click in anchor tag it is redirecting to page
but same code js when I am pasting in downloaded solution it is working
so is there any DLL or same think need to added to work routing in angular Js
Index.html
@{
ViewBag.Title = "Index";
}
<script type="text/javascript" src="@Url.Content("~/Scripts/angular.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/angular-route.min.js")"></script>
<script src="~/Scripts/Home/Module.js"></script>
<script src="~/Scripts/Home/Services.js"></script>
<script src="~/Scripts/Home/ManageUserController.js"></script>
<body data-ng-app="UserModule">
<h2>Manage User</h2>
<a href="ManageUser">Manage</a>
<div data-ng-view></div>
</body>
ManageUser.cstml
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Role</th>
<th>Edit</th>
</tr>
<tr data-ng-repeat="user in users">
<td>
{{user.FirstName}}
</td>
<td>
{{user.LastName}}
</td>
<td>
{{user.RoleName}}
</td>
<td></td>
</tr>
</table>
Module.js
var app = angular.module("UserModule", ["ngRoute"]);
app.factory("ShareData", function () {
return { value: 0 }
});
app.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
$routeProvider.when('/ManageUser',
{
templateUrl: 'Home/ManageUser',
controller: 'ManageUserController'
});
$routeProvider.otherwise(
{
redirectTo: '/'
}
);
$locationProvider.html5Mode(true).hashPrefix('!')
}]);
Services.js
app.service('SPAUserServices', function ($http) {
this.getUsers = function () {
return $http.get('/Home/GetUsers')
};
});
ManageUserController.js
app.controller('ManageUserController', function ($scop, $location, SPAUserServices, ShareData) {
getUserbind();
function getUserbind() {
var dataload=SPAUserServices.getUsers();
dataload.then(function (pl) { console.write(pl.data); $scop.Users=pl.data},
function (errorpl)
{
$scop.error = errorpl;
console.write(errorpl);
}
);
}
});
HomeController.cs
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public JsonResult GetUsers()
{
return Json(new List<UserModel> {
new UserModel { UserID = 1, FirstName = "Sushant", RoleName = "Admin" }
, new UserModel { UserID = 2, FirstName = "Nilesh", RoleName = "User" }
},JsonRequestBehavior.AllowGet);
}
public ActionResult ManageUser()
{
return PartialView("ManageUser");
}
}
public class UserModel
{
public int UserID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public int strRoleID { get; set; }
public string RoleName { get; set; }
}