airfranceklm / ng-lazy-image

Angular directive for loading responsive image when container (which is preventing reflow) is in viewport.
http://afklm.github.io/ng-lazy-image/
MIT License
351 stars 64 forks source link

Unwanted 404 requests to the server when url is not provided (undefined) #52

Closed manuel-di-iorio closed 8 years ago

manuel-di-iorio commented 8 years ago
span(ng-show="img")
    .afkl-lazy-wrapper(afkl-lazy-image="http://url.com/{{img}}")

That's how I was hoping to resolve this issue but unfortunately this lib still makes a request when img is undefined

Same issue even using ng-show on the directive itself. Same, also putting the full image url in the scoped variable.

Have you any idea on how to handle this situation ? Thank you

manuel-di-iorio commented 8 years ago

Resolved using ng-if, thanks anyway ^_^

SquadraCorse commented 8 years ago

i just wanted to say that in your controller make sure if image not given give fallback url. But an if statement as wrapper should work too indeed. Good luck!

manuel-di-iorio commented 8 years ago

Thanks @SquadraCorse but my little situation is different, I just need to not load and display that image when the url is not provided, but I'll keep your advice in mind for other cases ;)