AngularJS ng-src Directive
Definition and Usage
ng-src
directive will override <img>
The original src
attribute.
If you include AngularJS code in the src value, you should use ng-src
directive replaces src
.
ng-src
The directive ensures that the image will not be displayed incorrectly before the AngularJS code is evaluated.
Example
Add an image where src is calculated by AngularJS:
<div ng-init="myVar = 'pic_angular.jpg'"> <h1>Angular</h1> <img ng-src="{{myVar}}"> </div>
Syntax
<img ng-src="string</img>
Affected <img>
Element Support.
Parameter
Parameter | Description |
---|---|
string | String value, or expression result is a string. |