AngularJS ng-srcset 指令

definition and usage

ng-srcset The directive will override the original srcset attribute.

If the srcset value contains AngularJS code, you should use ng-srcset directive replaces srcset.

ng-srcset The directive ensures that the image will not be displayed incorrectly before the AngularJS code is evaluated.

Example

Add an image where srcset is calculated by AngularJS:

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

Try it yourself

Syntax

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

affected <img> and <source> Element support.

Parameter

Parameter Description
string String value, or expression result is a string.