Tutorials Exercises Get Certified Services Menu
Log in
Sign Up Spaces Bootcamps

AngularJS ng-src Directive


Add an image, where the src is evaluated by AngularJS:

<div ng-init="myVar = 'pic_angular.jpg'">
    <img ng-src="{{myVar}}">
Try it Yourself »

Definition and Usage

The ng-src directive overrides the original src attribute of an <img> element.

The ng-src directive should be used instead of src if you have AngularJS code inside the src value.

The ng-src directive makes sure the image is not displayed wrong before AngularJS has evaluated the code.


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

Supported by the <img> element.

Parameter Values

Value Description
string A string value, or an expression resulting in a string.