i want to pass the json data from controller to angularjs..i have tried the below code but just only show the table header don't show my product data..below put my code.. this is my angularjs code..
$scope.ViewPro = function () {
$http({ method: 'GET', url: 'AddToCart/ProList' }).
success(function (p) {
debugger;
console.log(p);
$scope.Products = p;
$location.path('/ViewProduct');
}).
error(function (data) {
alert(data + "Error");
console.log(data);
});
};
this is my json controller method..
public JsonResult ProList()
{
var ProductList = db.tblProducts.ToList();
var Products = ProductList.Select(d => new
{
d.ProductId,
d.ProductName,
d.Price,
d.Descripation,
d.SEOURL,
d.Image,
d.IsPubliesd,
}).ToList();
return Json(Products, JsonRequestBehavior.AllowGet);
}
this is my routeProvider
.when('/ViewProduct', { templateUrl: 'AddToCart/ViewProduct' })
this is my view..
<div ng-app="MyApp" ng-controller="AddToCart" ng-model="AddToCart">
<div class="table-responsive">
<table class="table table-striped table-bordered">
<tr>
<td align="center">ProductId</td>
<td align="center">ProductName</td>
<td align="center">Descripation</td>
<td align="center">Price</td>
<td align="center">SEOURL</td>
<td align="center">IsPubliesd</td>
<td align="center">AddToCart</td>
</tr>
<tr ng-repeat="Product in Products">
<td ng-bind="Product.ProductId"></td>
<td>{{Product.ProductName}}</td>
<td>{{Product.Descripation}}</td>
<td>${{Product.Price}}.00</td>
<td>{{Product.SEOURL}}</td>
<td>{{product.ispubliesd}}</td>
</tr>
</table>
</div>
</div>
What I have tried:
i want to show my product data but i get the error just only show table header don't show my data i tried the above code but i am not get perfect result so please any one idea so please help me..