Angular2 Image Fallback
Load placeholder image on image error
Angular 2 directive that loads placeholder image on primary image error.
Install
npm install ng2-img-fallback --save
Usage
In case you're using SystemJS
see configuration here
Add module to your module's imports
;;; ;
Use it in you component
;
Events
(loaded)
ng2-img-fallback
provides (loaded)
event which is fired when either src
or src-fallback
is loaded.
To determinate whether original source or fallback is loaded - add a param to your callback for the (loaded)
event.
Example:
First add callback to your component
onLoadedisFallback: boolean
and then bind it to the loaded
event