View source Improve this doc

ngSrcset
directive in module ng

Description

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

The buggy way to write it:

<img srcset="http://www.gravatar.com/avatar/{{hash}} 2x"/>

The correct way to write it:

<img ng-srcset="http://www.gravatar.com/avatar/{{hash}} 2x"/>

Usage

as attribute
<IMG ng-srcset="{template}">
   ...
</IMG>

Parameters

ParamTypeDetails
ngSrcsettemplate

any string which can contain {{}} markup.