AngularJS ng-src Instruction
AngularJS Examples
Add an image address:
<
div
ng-init=
"myVar = 'http://www.runoob.com/wp-content/uploads/2014/06/angular.jpg'"
<
h1
Angular
<
/h1
<
img
ng-src=
"{{myVar}}"
<
/div
Try it »
Definition and Usage
ng-src The directive overrides the element's src attribute.
If you use AngularJS code to set the image address, please use ng-src directive instead of src attribute.
ng-src The directive ensures the image is not displayed before the AngularJS code executes.
Syntax
<
img
ng-src=
"string"
<
/img
elements support this attribute.
Parameter value
| Value | Description |
|---|---|
| string | A string returned by the expression. |
AngularJS Reference Manual