我在删除对我的帖子的评论时遇到问题。你会怎么做?我正在使用 Angular NGXS 状态管理。请看这个链接
onDeleteComment(commentId: number){
this.store.dispatch(new DeleteComment(commentId));
}
@Action(DeleteComment)
deleteComment(
ctx: StateContext<PostStateModel>,
{ commentId }: DeleteComment
) {
const state = ctx.getState();
const filteredArray = state.post.comments.find(
item => item.id === commentId
);
console.log(filteredArray);
}