ngSrcset (directive)

Improve this Doc View Source ngSrcset

  1. directive in module ng

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"/>

Directive Info

  • This directive executes at priority level 99.

Usage

  • as attribute:
    <IMG
      ng-srcset="">
    ...
    </IMG>

Arguments

Param Type Details
ngSrcset template

any string which can contain {{}} markup.

© 2010–2016 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://code.angularjs.org/1.2.32/docs/api/ng/directive/ngSrcset

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部