【发布时间】:2017-01-31 05:24:00
【问题描述】:
我创建了一个下面的工厂,它应该通过将 url 和输入参数作为 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);
}
一切都好,工厂调用api但不发送参数值,我的api总是设置/初始化为空值。
【问题讨论】:
标签: javascript angularjs asp.net-mvc c#-4.0