0
当我写了一个自定义操作$资源这样的:
getEntityResource(): ng.resource.IResourceClass<IEntityResource> {
let addAction: ng.resource.IActionDescriptor = {
method: 'POST',
url: 'http://localhost:8085/api/entity/add'
}
return <ng.resource.IResourceClass<IEntityResource>>
this.$resource("http://localhost:8085/api/entity/:entityId", { id: '@id' }, {
add: addAction,
});
,并从控制器这样称呼它:
this.$mdDialog.hide(this.dataService
.getEntityResource()
.add(this.entity,
() => this.$state.reload()
));
该呼叫是这样发送的:
Request URL:http://localhost:8085/api/entity/add?id=0
webApi操作正在接受实体对象作为参数不是ID:
[HttpPost]
public Entity Add(Entity entity)
问题是它发送带有字符串参数(?id = 0)的post请求而不是JSON对象。
我错过了什么?
谢谢。
您是否收到任何错误?有什么问题? –
它发送一个查询字符串/ add?id = 0而不是JSON对象。 – Tuximo