Angular 2 @ViewChild returns undefined

后端 未结 6 1225
南旧
南旧 2020-12-15 02:57

I\'ve looked at several related posts and documentation, but still can\'t seem to get expected behavior from @ViewChild.

Ultimately, I\'m trying to set the scroll p

6条回答
  •  感动是毒
    2020-12-15 03:29

    I had a similar issue. Unlike you, my @ViewChild returned a valid ElementRef, but when I tried to access its nativeElement, it was undefined.

    I resolved it by setting the view id like #content, not like #content = "ngModel".

    
    

提交回复
热议问题