English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Add image address:
!DOCTYPE html <html> <head> <meta charset="utf-8"> <script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script> </head> <body ng-app=""> <div ng-init="myVar = 'http://www.oldtoolbag.com/wp-content/uploads/2014/06/angular.jpg'"> <h1>Angular</h1> <img ng-src="{{myVar}}"> </div> <p>This example can use the original src output, but uses AngularJS code to insert values, using ng-The src attribute is better.</p> </body> </html>Test to see ‹/›
ng-src The directive overrides the src attribute of the <img> element.
If you have used AngularJS code to set the image address, please use ng-src Directive Replacement src
attribute.
ng-src The directive ensures that the image is not displayed before the AngularJS code is executed.
<img ng-src="string></img>
The <img> element supports this attribute.
Value | Description |
---|---|
string | The string returned by the expression. |