sorry if im doing something wrong im new here '^^
im curently working on a school project building a website using MVC. im trying to load objects from a database using Json object and angularJS.
i have an action in a contoller called "GetProductsByJson" it returns a Json object containing a list of products. this is the action:
public ActionResult GetProductsByJson()
{
HomeModel homeModel = new HomeModel();
DataLayer prodDal = new DataLayer();
homeModel.productList = prodDal.Products.ToList<Product>();
return Json(homeModel.productList,JsonRequestBehavior.AllowGet);
}
the action it self works good (i tested it individualy) but when im trying to use it in the angular script its just not working (it doesnt even go into the method).
this is the angular script:
<script>
var app = angular.module("myProduct", []);
app.controller("ProductViewModel", function ($scope,$http) {
$scope.Product = {
"prodName": "",
"price": "",
"amount": "",
"serial": "",
"lastUpdate": "",
"pic": ""
};
$scope.Products = {};
$scope.LoadProducts = function () { //load data from the server
debugger
$http({ method: "GET", url: "LoadProducts" }).
success(function (data, status, headers, config) {
$scope.Products = data;
});
};
$scope.LoadProducts();
});
</script>
i tried routing the action in the RouteConfig but nothing works.
ok im really sorry for the trouble problem solved.
i had to insert the full url of the action apperntly.