Angular

">

Angular

" />
Easy Tutorial
❮ Ng Ng Style Ng Ng Keydown ❯

AngularJS ng-srcset Directive

AngularJS Reference Manual


AngularJS Example

Define the resource address of an image:

<div ng-init="myVar = 'http://www.tutorialpro.org/wp-content/uploads/2014/06/angular.jpg'">
   <h1>Angular</h1>
   <img ng-srcset="{{myVar}}">
</div>

Definition and Usage

The ng-srcset directive overrides the srcset attribute of the <img> element.

If you use AngularJS code to set the image address, use the ng-srcset directive instead of the srcset attribute.

The ng-srcset directive ensures that the image is not displayed before the AngularJS code is executed.


Syntax

The attribute is supported by <img> and <source> elements.


Parameter Values

Value Description
string The string returned by the expression.

AngularJS Reference Manual

❮ Ng Ng Style Ng Ng Keydown ❯