angularjs - ng-src throws a 404 because my img is not set yet -


I have an image that has an image (for a preview), only when shown in an image source set Ho. My problem is that I get 404 because there is no image set in the beginning.

  & lt; Div ng-show = "imgSrc" class = "preview" & gt; & Lt; Div class = "menu" & gt; & Lt; A ng-click = "imgSrc = false" class = "btn btn-primary" & gt; & Lt; I class = "fa-ef-times" & gt; & Lt; / I & gt; Close & lt; / A & gt; & Lt; One class = "btn btn-primary" href = "{{imgSrc}}" & gt; & Lt; I class = "fa fa-download" & gt; & Lt; / I & gt; Download & lt; / A & gt; & Lt; Img ng-src = "{{imgSrc}}" /> / * & Lt; --------------------- here * / & lt; / Div & gt;   

Is this a good way to do it? Or should I remove the image tag, and when an IMG is set it should be added? In this case, how can I add elements? 404 means that the image is not present on the server, it does not mean that

is not defined.

If you do not define imgSrc then you want to hide the element, then use the nh-show command, as you already have Additionally, make sure that there is no default value in imgSrc .

If you want to see that the image is present before it is displayed on the server, then you need to request an AJAX request for that URL and check back the response.

Edit

In addition to ng-click = "IMGSRC = false" should be ng-click = "IMGSRC = ''" < / Code>.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -