I'm wondering a long time and I can't find a solution, maybe someone of you resolved a similar problem.
Let's say we want to pass and array of objects via $http service to the MVC Controller. This array is created in angular so I don't know the proper type (just var). The problem is I don't know what type of parameter should be in MVC function
AngularJS Controller
$scope.DoSth = function (){
var data = [{
Id: "1",
Value: "apple"
},
{
Id: "2",
Value: "banana"
}];
};
//DoSthService injected into angular controller
DoSthService.doSth(data)
.success(function(result){
//sth with success result
})
.error(function(result){
//sth with error result
});
AngularJS Service:
this.doSth = function(data){
var response = $http({
method: "post",
url: "Home/DoSth",
data: data
//or data: JSON.stringify(data) ??
});
return response;
};
MVC Controller:
public string DoSth(**what type here?** data)
{
//do sth and return string
}
Could anyone help me?