我正在尝试测试父级子组件,父级测试成功,但是我在oninit中调用@output属性的子项失败“无法读取未定义的属性'id'”
export class SinglepostComponent implements OnInit {
@Input() post: Post;
@Input() posts: Array<Post>;
public comments: Array<Comment>;
public comm: Comment;
constructor(
private postService: PostService,
private dataService: DataService,
public dialog: MatDialog,
public commentservice: CommentService
) { }
ngOnInit() {
this.postService.getComments(this.post.id).subscribe(data => {
this.comments = data;
});
}