这里我正在使用应用程序/ json,但我不能获取方法
Service.js
AddEmp(Emp: Employee): Observable<Employee[]> {
let headers = new Headers({ 'Content-Type': 'application/json' });
let body = JSON.stringify(Emp);
let options = new RequestOptions({ headers: headers });
return this._http.post(this.Url2, +body, options).map(this.extractData).catch(this.handleError);
}
private extractData(res: Response) {
let body = res.json();
return body || {};
}
这里我正在消费我的服务 的 Component.ts
submit(data: Employee){
this._HttpService.AddEmp(data)
.subscribe(data => this.Employees = data, error => console.log(data), () => console.log());
}
的WebAPI
[Route("SaveEmp")]
[HttpPost]
public string SaveData(Employee emp)
{
return "OK";
}