我在将数据从An2发布到WebApi
时收到此错误Service.ts
AddEmp(Url2: string, model): Observable<any> {
let body = JSON.stringify(model);
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this._http.post(this.Url2, body, options)
.map((response: Response) => <any>response.json())
.catch(this.handleError);
}
Component.ts
Employees: Employee[] = [];
submit(EmpData): any{
this._HttpService.AddEmp(this.Url2, EmpData)
.subscribe(data => {
EmpData = data, error => console.log(), () => alert('ok...')
});
}
答案 0 :(得分:0)
我现在遇到了这个问题。
原因是事件命名。
将@Output命名为// In emitter
<form (ngSubmit)="onSubmit($event);" > ...
@Output submit = new EventEmitter<any>(); ...
onSubmit(event) {
this.submit.emit(this.formGroup.value); // Event('submit') triggered
}
// In subscriber:
(submit)="onSave($event)"
onSave(data) {
// There are 2 events triggered.
// - Our manually triggered form data
// - Original submit Event with public {isTrusted: true} property.
this.http.post(uri, data); // So, we call two consequent POST query
}
时,还会收到默认的传播事件。
onSubmit(event) { event.stopPropagation(); ...
停止原始事件传播:
submitData
将自定义事件重命名为library(zoo)
rollapply(1:ncol(anscombe), 4, by = 2, function(ix) sum(anscombe[, ix]))