2017-02-07 14 views
0

AngularJS $ http getを使用してデータを取得する方法を知っていますが、$ http get with parametersを使用して.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」を使用)に渡すように置いてください教えてもらえますか?そしてコードはありませんか?ありがとう!

+0

参考:https://docs.angularjs.org/api/ng/service/$httpと設定を確認します –

答えて

0

試してみてください。

$http({ 
    url: url, 
    method: "GET", 
    params: { sendToWS: ... } 
}); 
関連する問題