@ViewChild always returns undefined

前端 未结 3 631
北恋
北恋 2021-02-13 14:36

I know this has been asked before, but none of the selected answers are working for me.

I am trying to use @ViewChild to get my ng-select from t

3条回答
  •  深忆病人
    2021-02-13 14:46

    I replaced all occurrences of

    *ngIf="flag"
    

    with

    [style.display]="flag ? 'block' : 'none'"
    

    to get this to work consistently in my case. Otherwise the ViewChild components that didn't exist when my view first loaded would potentially remain undefined for ever.

提交回复
热议问题