【发布时间】:2020-03-15 19:51:25
【问题描述】:
HTML 内容:
<td>
<a (click)="onDelete(item.id)">
<i class="material-icons" style="font-weight:bold; font-style:inherit ;color: rgba(247, 37, 37, 0.884);">
delete_outline
</i>
</a>
</td>
对应的TS文件:
onDelete(id) {
console.log(id);
this.blogId = this.id;
const status = window.confirm('Are you sure you want to delete this id?' + this.blogId);
if (status) {
this.blog.deleteBlog(this.blogId).subscribe((response) => {
this.blogId = (Response);
alert('Successfully deleted the id');
this.route.navigate(['/admin/blogger']);
}, (error) => {
console.log(error);
});
}
还有服务文件:
deleteBlog(id: any) {
return this.http.delete(this.mainUrl + '/blog/' + id);
}
当我尝试将 id 作为参数传递以删除某些记录时,控制台中出现未定义错误。我不知道我在这里做错了什么。提前致谢。
【问题讨论】:
标签: json angular typescript api angular6