我试图发布一组未发送到服务器的数据:
网络服务:
deleteCategory() {
return this.http.post('http://www.demo/webapi/deletecategory', {
headers: {
"Authorization": "Token " + this.token,
"Content-Type": "application/x-www-form-urlencoded"
},
withCredentials: true
}
)
}
Run Code Online (Sandbox Code Playgroud)
在 ts 文件中
onDelete() {
this.userService.deleteCategory().subscribe(response => {
this.selectedArray = [];
for (var i = 0; i< this.selection._selected.length; i++){
this.selectedArray.push(this.selection._selected[i].category_id) ;
console.log(' selected value:', this.selectedArray);
}
})
}
Run Code Online (Sandbox Code Playgroud)
在 html 中
<button class="btn-danger pull-right" (click)="onDelete()" type="button" >Delete</button>
Run Code Online (Sandbox Code Playgroud)