Angularjs 每当添加新行时,如何在ng2智能表中使用post方法?
我在angular 2项目中使用了Angularjs 每当添加新行时,如何在ng2智能表中使用post方法?,angularjs,angular,post,ng2-smart-table,Angularjs,Angular,Post,Ng2 Smart Table,我在angular 2项目中使用了ng2智能表,当向表中添加新行时,我需要使用http.post()方法发送API请求。如何获取新添加行中每个单元格的值?HTML <ng2-smart-table [settings]="settings" [source]="data" (createConfirm)="onPostCall($event)" (editConfirm)="onPostCall($event)"> </ng2-smart-table> 更新时[TS]
ng2智能表
,当向表中添加新行时,我需要使用http.post()
方法发送API
请求。如何获取新添加行中每个单元格的值?HTML
<ng2-smart-table
[settings]="settings"
[source]="data"
(createConfirm)="onPostCall($event)"
(editConfirm)="onPostCall($event)">
</ng2-smart-table>
更新时[TS]
onPostCall(event){
event.confirm.resolve(event.newData);
// console.log(event.newData); //this contains the new edited data
//your post request goes here
// example
const req = http.post('/api/items/add', body);
// 0 requests made - .subscribe() not called.
req.subscribe();
// 1 request made.
}
参考:
onPostCall(event){
event.confirm.resolve(event.newData);
// console.log(event.newData); //this contains the new edited data
//your post request goes here
// example
const req = http.post('/api/items/add', body);
// 0 requests made - .subscribe() not called.
req.subscribe();
// 1 request made.
}