Skip to content
Related Articles

Related Articles

Improve Article

AngularJS | ng-srcset Directive

  • Last Updated : 28 Mar, 2019

The ng-srcset Directive in AngularJS is used to specify the srcset attribute of an <img> element. It ensures that the wrong image is not produced until AngularJS has been evaluated. It is supported by <img> and <source> element.

Syntax:

<img ng-srcset="url"> </img> 

Example:




<!DOCTYPE html>
<html>
    <head>
        <title>ng-srcset Directive</title>
        <script src=
        </script>
  
    </head>
    <body ng-app="app" style="text-align:center">
      <h1 style="color:green">GeeksforGeeks</h1>
      <h2>ng-srcset Directive</h2>
        <div ng-controller="geek">
            <img ng-srcset="{{pic}}" /><br><br><br>
        </div>
        <script>
            var app = angular.module("app", []);
            app.controller('geek', ['$scope', function ($scope) {
                $scope.pic = 
            }]);
        </script>
    </body>
</html>

Output:
ngsrcset

My Personal Notes arrow_drop_up
Recommended Articles
Page :