Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

prevent image from loading if ng-show is false? #7926

Closed
vishnu4 opened this issue Jun 20, 2014 · 3 comments
Closed

prevent image from loading if ng-show is false? #7926

vishnu4 opened this issue Jun 20, 2014 · 3 comments

Comments

@vishnu4
Copy link

vishnu4 commented Jun 20, 2014

I have some code where i would only like to show an image object if it is a valid file type, so i have something like:

<img ng-show='isFileAnImage(FileName)===true' alt='{{dataItem.FileName}}' ng-src='"{{ FileURL }}' />

which works great (img is only showing if it passes my validation). But looking through the network traffic, the page is still trying to call the image src URL, even when not valid. I've tried wrapping the img in a div, and putting the ng-show there instead, but no luck. Is there a way to avoid the call to ng-src if ng-show is false?

@btford btford self-assigned this Jun 20, 2014
@btford
Copy link
Contributor

btford commented Jun 20, 2014

What version of Angular are you using?

@vishnu4
Copy link
Author

vishnu4 commented Jun 20, 2014

1.2.18

@btford btford added this to the Backlog milestone Jun 20, 2014
@btford
Copy link
Contributor

btford commented Jul 21, 2014

The unnecessary request to the server was fixed in 8d18038. If you want this kind of behavior in 1.2.x, you use ng-if instead of ng-show.

Please read the contributing guidelines; you're likely to get more answers to questions like this elsewhere.

@btford btford closed this as completed Jul 21, 2014
@btford btford removed their assignment Jul 21, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants