Conditionally change img src based on model data

Instead of src you need ng-src.

AngularJS views support binary operators

condition && true || false

So your img tag would look like this

<img ng-src="https://stackoverflow.com/questions/13999659/{{interface =="UP' && "https://stackoverflow.com/questions/13999659/green-checkmark.png" || 'big-black-X.png'}}"/>

Note : the quotes (ie “https://stackoverflow.com/questions/13999659/green-checkmark.png”) are important here. It won’t work without quotes.

plunker here (open dev tools to see the produced HTML)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)