Improve this Doc View Source ngSrcset

From Get docs
< Directive components in ngAngularjs/docs/1.8/api/ng/directive/ngsrcset

Improve this Doc View Source ngSrcset

  1. directive in module ng


Using AngularJS markup like Template:Hash in a srcset attribute doesn't work right: The browser will fetch from the URL with the literal text Template:Hash until AngularJS replaces the expression inside Template:Hash. The ngSrcset directive solves this problem.

The buggy way to write it:

<img srcset="{{hash}} 2x" alt="Description"/>

The correct way to write it:

<img ng-srcset="{{hash}} 2x" alt="Description" />

Directive Info

  • This directive executes at priority level 99.


  • as attribute:



Param Type Details
ngSrcset template any string which can contain {{}} markup.

© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.