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
Post a Comment