I have an HTML form which has the following values:
<input ng-model="person.id"/><br/>
<input ng-model="person.name" /><br />
<input ng-model="person.lastname" /><br />
<button ng-click="callAPI()">Call API</button>
When clicked I call this function
$scope.callAPI = function () {
var person = {
id: $scope.person.id,
name: $scope.person.name,
lastname: $scope.person.lastname
};
$http.post('/api/save/SavePerson', person).success(function (data) {
$scope.returnValue = data;
}).error(function (data) {
$scope.error = "An Error has occured while Saving person! " + data;
$scope.loading = false;
});
};
I'm trying to pass it to my SavePerson method within my API as shown here:
[System.Web.Http.AcceptVerbs("GET", "POST")]
[System.Web.Http.HttpGet]
public void SavePerson([FromBody]PersonModel person)
{
var dooda = string.Empty;
}
The PersonModel looks like this :
public class PersonModel
{
public int id { get; set; }
public string name { get; set; }
public string lastname { get; set; }
}
However when I click "CallAPI()" and hit the break point within SavePerson the person model is null?