asp.net mvc - AngularJs push doesn't work -


i'm trying send json value mvc webapi controller... angularjs controller looks this...

addmodule.controller('addemployeectrl', ['$scope', '$http', function ($scope, $http) {  //to push roleid , rolename addemployee variable $scope.emplist = [];  //on-click function $scope.submitchanges = function (addemployeedata) {      //to push roleid , rolename addemployee variable     var roleitem =         {             rolename: addemployeedata.role.rolename,             roleid: addemployeedata.role.roleid         };     $scope.emplist.push(roleitem);      //creating variable post other end     var addemployee = {         username: addemployeedata.username,         employeelastname: addemployeedata.lastname,         employeefirstname: addemployeedata.firstname,         role: $scope.emplist                 };              $http.post('/api/employeeapi/createemployee/' , json.stringify(addemployee), { headers: { 'content-type': 'application/json' } }) 

when try send webapi controller, won't grab role value in addemployee variable... roles value null... enter image description here

you sending role instead of roles

convert

role: $scope.emplist  

to this

roles: $scope.emplist  

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -