customerLogin是我想要发送给我的服务的对象。 我不想使用查询字符串,也不想单独分开参数。 下面是代码:
var config = {
customerLogin : { // object I intend to send
'EmailID': $scope.existingCustomer.email,
'PhoneNumber': $scope.existingCustomer.phoneNumber,
'Passkey': $scope.existingCustomer.password
}
}
$http.get(existingCustomerUrlConstant, config).
在的WebAPI,我有下面的代码:
[HttpGet]
// customerLogin object i want to receive here
public CustomerLogin GetCustomer(CustomerLogin customerLogin)
{
GetCustomerDAL getCustomerDAL = new GetCustomerDAL(customerLogin);
return customerLogin;
}
customerLogin为空在这里。 如何从角度服务呼叫接收对象?
你确定你不想用POST方法吗? –
如果你想通过'HTTP GET'发送额外的数据,你必须使用查询字符串或URL本身。这就是GET的工作方式。如果你不想在URL中有任何数据,那么你必须使用POST,PATCH,PUT等等...... –
@ZdenekHatak:自从我获取数据后,我想到了使用GET。用POST,它工作正常。我认为这将是一个好习惯。 – Amit