html - Check if img-src exists with angular -


i want simple determination if image source exists or not, can replace image default image. best case if possible in pure html maybe "ng-if" or this.

<img ng-if="../images/{{id}}.png"  src="../images/{{id}}.png"> 

this code doesn't work, think shows want.

edit:

new code got, work in opinion, doesn't work:

<img ng-src='{{ "../images/{{id}}.png" || "../images/img.png" }}'/> 

debugger says wrong quotes in case.

edit:

i think second solution works, there bug in part:

<img ng-src='{{"../images/{{id}}.png"}}'/> 

this part works:

<img ng-src='{{"../images/img.png"}}'/> 

you can use onerror, here demo.

<img ng-src="http://experenzia.com/images/431f5cfa87f2faf9317ccc89e980dcca/431f5cfa87f2faf9317ccc89e980dcca_t.jpg" onerror="this.src='http://www.experenzia.com/assets/images/planner/no-image-back.png'" alt="" > 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -