How to post json data using angularjs? -


i try below logic, not working.

in angular js:

    $scope.save = function () {      var items = $scope.invoice.items;     var obj = [{ smembercode: 'alma0502' }];       var request = $http({         method: "post",         url: sserviceurl + 'savedata',         data: obj     });  }; 

in wcf service :

[operationcontract]

    [webinvoke(uritemplate = "savedata",         requestformat = webmessageformat.json,         responseformat = webmessageformat.json, method = "post")]     bool savedata(wcfservice1.common obj); 

please tell me wrong...

try this

this.post = function (itemdetails) {     $http.post('http://localhost:4191/service1.svc/additemmaster', itemdetails).         success(function (data) {             console.log('data', data);             // when call successful code here          }).         error(function (err){             console.log('error:', err);         }); }; 

did inject $http service in controller? this:

var app = angular.module('youappmodule', []); app.controller('controllername',['$http', function($http){  // above code in here   }]); 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -