AngularJS ng-srcset directive
AngularJS instance
Define the resource address of the image:
<!DOCTYPE html><html><head><meta charset="utf-8"><script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script></head><body ng-app=""><div ng-init="myVar = 'http://www.runoob.com/wp-content/uploads/2014/06/angular.jpg'"><h1>Angular</h1><img ng-srcset="{{myVar}}"></div><p>This instance can use native srcset Output, but using AngularJS code to insert values, the ng-srcset property is better. </p></body></html>Definition and usage
The ng-srcset directive overrides the srcset property of the <img> element.
If you use AngularJS code to set the image address, use the ng-srcset directive instead of the srcset property.
The ng-srcset directive ensures that the AngularJS code does not display images before execution.
grammar
<img ng-srcset="string"></img>
The <img> and <source> elements support this property.
Parameter value
| value | describe |
|---|---|
| string | The string returned by the expression. |
The above is the basic information of the ng-srcset instruction. We will continue to organize it later. Thank you for your support for this website!