VOOZH about

URL: https://www.geeksforgeeks.org/angular-js/angularjs-ng-srcset-directive/

⇱ AngularJS ng-srcset Directive - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

AngularJS ng-srcset Directive

Last Updated : 11 Jul, 2025

The ng-srcset Directive in AngularJS is used to specify the srcset attribute of an <img> element, ie, overriding the original srcset attribute of an <img> element. It helps to ensure that the wrong image is not produced until AngularJS has been evaluated. This directive must be used instead of using the srcset, especially when the required AngularJS code is inside of the srcset value. It is supported by <img> and <source> element. 

Syntax:

<img ng-srcset="url">

Parameter value:

  • url: It represents the expression or a string value, whose final output will be a string.

Example 1: This example describes the implementation of the ng-srcset Directive in AngularJS.

Output:

👁 ngsrcset

Example 2: This is another example that illustrates the use of the AngularJS ng-srcset Directive.

Output:

👁 Image
 
Comment

Explore