Angular 2 unit testing - @ViewChild is undefined

前端 未结 5 949
情歌与酒
情歌与酒 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:35

    Even after following everything from the accepted answer, you are getting undefined instance of child component then kindly check if that component is visible.

    In my case, there was *ngIf applied on the control that's why instance of child was undefined then I removed and checked and it worked for me

提交回复
热议问题