AngularJS Basic ng srcset Simple Example
- 2021-07-07 06:28:55
- OfStack
AngularJS ng-srcset Directive
AngularJS instance
Define the resource address of the picture:
<!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 the native srcset Output, but use the AngularJS Code inserts values, using the ng-srcset Attributes are better. </p>
</body>
</html>
Definition and usage
The ng-srcset directives override the
<
img
>
The srcset attribute of the element.
If you use the AngularJS code to set the image address, use the ng-srcset directive instead of the srcset attribute.
The ng-srcset directive ensures that the AngularJS code does not display a picture before execution.
Grammar
<
img ng-srcset="string"
>
<
/img
>
<
img
>
And
<
source
>
Element supports this attribute.
Parameter value
值 | 描述 |
---|---|
string | 表达式返回的字符串。 |
The above is the ng-srcset instruction of the basic data collation, follow-up continue to collate, thank you for your support to this site!