Hack to pass second param using $http.post in AngularJS

Hack to pass second parameter using $http.post in AngularJS.


Posted: January 29, 2019. | By: mustafa

Angular function to get list of products using pages getting input from user.

 $scope.GetProductList = function () {

 $scope.requestPage = 1;
 // use $.param jQuery function to serialize data from JSON 
 var data = $.param({
 Page: $scope.requestPage,
 CategoryId: $scope.categoryId

var config = {
 headers: {
 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
 var test = $http.post('/Home/GetProductList', data, config)
 .success(function (result) {
 $scope.productList = result.Products;


}).error(function (data) {


Add Asp.Net MVC controller method to get product object and second param as requested page.

public JsonResult GetProductList(MyModel.Product prodObj, int page)
 // to do

Happy Coding!

related posts

Back to top