I am trying to load an image dynamically in angular, so that there is no image caching. However, I am seeing this error in console when I try the following in angular:
ERROR Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError:
Expression has changed after it was checked.
Previous value for 'src': 'assets/my-image.svg?1662363097161'.
Current value: 'assets/my-image.svg?1662363097162
Code inside HTML file:
<img [src]="getImagePath()" width="500"/>
Code inside Angular Component
getImagePath() {
const imagePath = `assets/my-image.svg?${Date.now()}`;
return imagePath;
}
How do I make sure the SVG is not cached and I don't see the console error?