TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dhilipkumar r
NA
100
4.7k
Angular JS Pass json data to mvc controller in the form of l
Jul 25 2019 8:15 AM
I need to pass json in the form of List to controller in Angular JS Post.
I have tried to send data in form of Json to get it as list in the MVC controller. But when I did it , I get only row count at MVC Controller. The variables in the list are null
Angular Js Controller
$scope.SaveTaxRange =
function
(){
var
formdata = $(
"#frmTaxSetup"
).serializeArray();
var
uniqueKey = { name:
"AngularJS"
, value:
"SaveTaxRange"
};
formdata.push(uniqueKey);
var
tableData = [];
try
{ $(
'#tablTaxRange tbody tr'
).each(
function
(index, element) {
//tableData = {}; tableData.push({
Min_amt: $(
this
).find(
'th:eq(0) input'
).val(),
Max_amt: $(
this
).find(
'th:eq(1) input'
).val(),
Tax_percent: $(
this
).find(
'th:eq(2) input'
).val(),
Tax_type: $(
this
).find(
'th:eq(3) input'
).val(),
});
tableData.push({
Min_amt: $(
this
).find(
'th:eq(0) input'
).val(),
Max_amt: $(
this
).find(
'th:eq(1) input'
).val(),
Tax_percent: $(
this
).find(
'th:eq(2) input'
).val(),
Tax_type: $(
this
).find(
'th:eq(3) input'
).val(),
});
});
}
catch
(e) { alert(e); }
uniqueKey = { name:
"lstTaxRangeSave"
, value: tableData };
formdata.push(uniqueKey);
var
data = {};
$(formdata).each(
function
(index, obj) {
data[obj.name] = obj.value;
});
$http({
url:
"/PayModule/Pay_mas_taxsetup"
,
method:
"Post"
,
data: {
"model"
: data }
})
.then(
function
(response){});
};
MVC Model
public
class
TaxSetupMaster
{
public
class
TaxRange
{
public
string Min_amt;
public
string Max_amt;
public
string Tax_percent;
public
string Tax_type;
public
string add;
}
public
List<TaxRange> lstTaxRangeSave { get; set; }
}
MVC Controller
[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
public
ActionResult Pay_mas_taxsetup( TaxSetupMaster model)
{
var
a = model.lstTaxRangeSave ;
//Here it shows rowcount 2 but the variables are null. Is it feasible to get the data from html?
}
Thanks in advance
Reply
Answers (
1
)
PDF Viewer with annotations in Angular
How to access multi dmnsnl array in web API Using angular