Please note, this is a STATIC archive of website www.w3schools.com from 05 May 2020, cach3.com does not collect or store any user information, there is no "phishing" involved.
THE WORLD'S LARGEST WEB DEVELOPER SITE

AngularJS ng-srcset Directive


Example

Add an image, where the srcset is evaluated by AngularJS:

<div ng-init="myVar = 'pic_angular.jpg'">
    <h1>Angular</h1>
    <img ng-srcset="{{myVar}}">
</div>
Try it Yourself »

Definition and Usage

The ng-srcset directive overrides the original srcset attribute of an element.

The ng-srcset directive should be used instead of srcset if you have AngularJS code inside the srcset value.

The ng-srcset directive makes sure the image is not displayed wrong before AngularJS has evaluated the code.


Syntax

<img ng-srcset="string"></img>

Supported by the <img> and <source> elements.


Parameter Values

Value Description
string A string value, or an expression resulting in a string.