我找到了如何使用AngularJS$http检索数据的教程,但找不到如何使用$http参数从.asmx webservice检索数据。
在我的AngularJS服务中,我有以下代码:
.factory('BoothDesignatedCoordsService', ['$http', function ($http) {
return {
// Might retrieved from db eventually
fnGetBoothDesignatedCoords: function (strBoothName, intFloorPlanID) {
var boothDesignatedCoords
strBoothName = "B29"
intFloorPlanID = 3;
var sendToWS;
try {
var JSONObj = {
BoothName: strBoothName,
FloorPlanID: intFloorPlanID
};
sendToWS = JSON.stringify(JSONObj)
}
catch (e) {
alert("error from fnGetBoothDesignatedCoords " + e)
}
try {
var url = "http://localhost:4951/wsIPS.asmx/fnGetBoothDesignatedCoords";
$http.get(url)
.success(function (data) {
var jsonData = JSON.parse(data);
boothDesignatedCoords = JSON.parse(jsonData);
alert("success");
})
}
catch (e) {
alert("error from fnGetBoothDesignatedCoords2 " + e)
}
return boothDesignatedCoords;
}
}
}])
有人可以告诉我应该在哪里放置参数(使用变量"sendToWS"(来传入吗?缺少任何代码吗?谢谢!
尝试:
$http({
url: url,
method: "GET",
params: { sendToWS: ... }
});