AngularJS ng-src
Directive
AngularJS Example
Adding an image URL:
<div ng-init="myVar = 'http://www.tutorialpro.org/wp-content/uploads/2014/06/angular.jpg'">
<h1>Angular</h1> <img ng-src="{{myVar}}"></div>
Definition and Usage
The ng-src directive overrides the src attribute of the <img> element.
If you use AngularJS code to set the image URL, use the ng-src directive instead of the src
attribute.
The ng-src directive ensures that the image is not displayed before the AngularJS code is executed.
Syntax
The <img> element supports this attribute.
Parameter Values
Value | Description |
---|---|
string | The string returned by the expression. |