Improve this Doc View Source ngSrc
- directive in module ng
Overview
Using AngularJS markup like {{hash}}
in a src
attribute doesn't work right: The browser will fetch from the URL with the literal text {{hash}}
until AngularJS replaces the expression inside {{hash}}
. The ngSrc
directive solves this problem.
The buggy way to write it:
<img src="http://www.gravatar.com/avatar/{{hash}}" alt="Description"/>
The correct way to write it:
<img ng-src="http://www.gravatar.com/avatar/{{hash}}" alt="Description" />
Directive Info
- This directive executes at priority level 99.
Usage
- as attribute:
<IMG ng-src="template"> ... </IMG>
Arguments
Param | Type | Details |
---|---|---|
ngSrc | template | any string which can contain |
© 2010–2018 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://code.angularjs.org/1.7.8/docs/api/ng/directive/ngSrc