2016-12-05 61 views
0

我想通過我的HTTP對象獲得如何在角度上向HTTP GET添加參數?

$http({ 
     method: 'GET', 
     url: '/requestoffwork' 
    }).then(function successCallback(response) { 

    }, function errorCallback(response) { 

    }); 

我嘗試這樣做,這是行不通的。

$http({ 
     method: 'GET', 
     url: '/requestoffwork', 
     someParam: $scope.dt 
    }).then(function successCallback(response) { 

    }, function errorCallback(response) { 

    }); 
+0

將其設置爲「發佈」並嘗試使用。 https://docs.angularjs.org/api/ng/service/$http#post – LMK

回答

2

如果你想添加參數GET查詢字符串,你需要使用params選項在config對象,像這樣:

$http({ 
    method: 'GET', 
    url: '/requestoffwork', 
    params : { 
    someParam: $scope.dt 
    }  
}).then(function successCallback(response) { 

}, function errorCallback(response) { 

}); 

希望幫助!