Why does the following statement throw an error?
Idea: To show an image from the normal URL. If it's not found (404), show a fallback image.
Work Done:
<img [src]='image_path + item.leafname' (error) ="[src] = 'fallback_path + item.leafname'" height="200px" class="card-img-top">
Error thrown:
Parser Error: Unexpected token '=' at column 7 in [[src] = 'image_path + item.leafname'] in ng:///AppModule/DashboardComponent.html@46:60
Other Answers:
I found alternative answers on Stack, which suggests using ng-src
for the usual image and onerror = "this.src='url'"
for a fallback image. But, how do I do the same using the [src] binding and (error) event binding?