Angular 2 unit testing - @ViewChild is undefined

前端 未结 5 1034
情歌与酒
情歌与酒 2021-02-06 20:59

I am writing an Angular 2 unit test. I have a @ViewChild subcomponent that I need to recognize after the component initializes. In this case it\'s a Timepicke

5条回答
  •  清歌不尽
    2021-02-06 21:34

    Make sure your child component does not have a *ngIf that is evaluating to false. If so, it will result in the child component as being undefined.

提交回复
热议问题