Passing 3 parameters from angularjs $resource to C# Web API Controller Post method, one of the parameters returns null -
i have been trying pass 3 parameters post method angularjs c# web api controller. information being passed angularjs service correctly. have tried many combinations on client , server side post method receive multiple parameters closest have come 2/3.
here code.
server side controller:
// post api/values
[httppost("{id}")] public iactionresult post(int id, string userid, [frombody]post post) { if(post.id == 0) { _repo.addpost(id, userid, post); } else { _repo.updatepost(post); } return ok(post); }
client side service: namespace myapp.services {
export class postsservice { private postsresource; constructor(private $resource: ng.resource.iresourceservice) { this.postsresource = this.$resource("/api/posts/:id"); } getpost(id) { return this.postsresource.get({ id: id }); } savepost(id, userid, posttosave) { return this.postsresource.save({ id: id }, { userid: userid }, posttosave).$promise; } deletepost(id) { return this.postsresource.delete({ id: id }).$promise; } } angular.module("myapp").service("postsservice", postsservice);
}
any tips or suggestions? appreciated!
Comments
Post a Comment