I am fetching a large number of image URLs from an API and display them in a angular 2 web application. Some of the URLs are broken and i want to replace them with a default
You can simply use a ternary operator for this use case. I am assuming that you are getting the responses from a remote server
 }})
If you don't want to have the image from server write the path in single quotes ''.
Here if the link is broken then it will go to onErrorFunction if it isn't broken the res.image will be loaded.