I have successfully implemented the get and delete function of post in my Angular app. My problem comes when you wanted to delete a comment inside a post. I'm trying to achieve it using NGXS. How will i be able to access it inside of the post so i can retrieve the comment to be able to delete it. Here's what i have done
CODE
onDeleteComment(id: number){
this.store.dispatch(new DeleteComment(id));
}
@Action(DeleteComment)
deleteComment(
{ getState, setState }: StateContext<PostStateModel>,
{ id }: DeleteComment
) {
const state = getState();
const filteredArray = state.posts.filter(item => item.id !== id);
setState({
...state,
posts: filteredArray
});
}