ViewChild works when I specify id like
<div #test_205626>test</div>
But when I do:
<div [attr.id]="test_id">test</div>
I get something like:
<div _ngcontent-gtn-c6="" id="test_205626">test</div>
in output html, but with an error in the same time:
Cannot read property 'nativeElement' of undefined
The code is:
test_id = 'test_205626';
@ViewChild('test_205626', {read: ElementRef, static: false}) private myScrollContainer3: ElementRef;
Why ViewChild doesn't work with [attr.id]?