I have an img tag in my HTML with src value supplied through property binding like this :
<img [src]="imgSrc" id="myimage">
imgSrc variable exists in the .ts file. Its value is a URL
When i try to access this URL in my .ts file using
document.getElementById('myimage').src
It is showing null. It works fine if I do not use property binding and supply the value directly in HTML template. When I console log document.getElementById('myimage')
, the proper img tag with correct src is logged. I have tried using @ViewChild instead of ID as well but that is also not working. I know I can use imgSrc variable in my .ts file but how to access src property.