I have created a below factory which is supposed to return some data based by taking url and an input paramenter as No.
(function () {
'use strict'
angular.module('MainApp').factory('GetData', ['$http', function ($http) {
return {
getCountries: function (url, No) {
return $http({
method: "GET",
url: url,
DNo: No,
});
}
}
}]);
})();
I have injected this factory to my controller and used as below.
GetData.getCountries('/General/API/GetDetails', $scope.No).then(function (res) {
console.log(res.data);
}, function (res) {
});
}
and here is my API.
public JsonResult GetDetails(string DNo)
{
var allCntry = entity.spGetCountries(DNo).ToList();
return Json(allCntry, JsonRequestBehavior.AllowGet);
}
All is good, the factory calls the api but does not send the parameter value, my API always set/initialized to null value.