I am reading angularjs $http.post shortcut method on the following site http://docs.angularjs.org/api/ng.$http#methods_post
it accept following 3 parameters.
post(url, data, config)
Currently i am facing an issue how to pass data from my view. Here is my view code which ask user to enter ID and ContactNumber.
<div data-ng-controller="postreq">
<form>
RequestID:<input type="text" data-ng-model="request.Id"/>
ContactNo:<input type="text" data-ng-model="request.newcontact"/>
<button data-ng-click="add()">Add</button>
</form>
</div>
Here what i am trying in my Angularjs controller and it is not working .. no idea how to get the entered values of request.Id and request.newcontact.
function postreq($scope, $http) {
$scope.add = function ()
{
$http.post(
'/api/request',
JSON.stringify(**?????? here i am confused how to pass data**),
{
headers: {
'Content-Type': 'application/json'
}
}
).success(function (data) {
$scope.request= data;
});
}