【发布时间】:2020-02-24 08:28:04
【问题描述】:
我需要知道是否有办法只刷新删除回复部分而不用 ngOnInIt() 刷新整个组件
public deleteReply(commentId, replyId) {
this.isLoadingReplyDelete = true;
this.discussionService.deleteReply(commentId, replyId).takeWhile(() => this.alive)
.subscribe(returnObj => {
if (returnObj.status === 200) {
this.isLoadingReplyDelete = false;
this.ngOnInit();
}
});
}
}
【问题讨论】:
-
const index = this.listData.data.indexOf(key); this.listData.data.splice(index, 1);然后你可以调用刷新获取数据api方法..
-
如果组件的一部分可以自己刷新,那么它应该是当前组件的子组件。
-
查看角度变化检测器angular.io/api/core/ChangeDetectorRef 并查看这篇文章blog.angular-university.io/…
标签: angular