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...
you sending role instead of roles
convert
role: $scope.emplist
to this
roles: $scope.emplist
Comments
Post a Comment