Javascript AngularJS服务:使用带参数的$http get从.asmx webservice检索数据
我已经找到了如何使用AngularJS$http get检索数据的教程,但找不到如何使用带参数的$http get从.asmx webservice检索数据 在我的AngularJS服务中,我有以下代码:Javascript AngularJS服务:使用带参数的$http get从.asmx webservice检索数据,javascript,angularjs,json,web-services,asmx,Javascript,Angularjs,Json,Web Services,Asmx,我已经找到了如何使用AngularJS$http get检索数据的教程,但找不到如何使用带参数的$http get从.asmx webservice检索数据 在我的AngularJS服务中,我有以下代码: .factory('BoothDesignatedCoordsService', ['$http', function ($http) { return { // Might retrieved from db eventually fnGetBoothDesignated
.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: ... }
});
参考:并检查配置