Tutorials References Exercises Bootcamps Videos Menu
Sign Up Create Website Get Certified Upgrade

AngularJS ng-srcset Directive


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

<div ng-init="myVar = 'pic_angular.jpg'">
    <img ng-srcset="{{myVar}}">
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.


<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.