Code Explanation for ng-srcset directive in AngularJS:
AngularJS is distributed as a JavaScript file, and can be added to a HTML page with a <script> tag.
The AngularJS application is defined by ng-app=" ". The application runs inside the <body> tag. It’s also used to define a <body> tag as a root element.
The ng-init=”source= ‘logo.png’ “ is used to define the initial value of the source variable is “logo.png” image.
The ng-srcset= “{{source}} 2x” is used to dynamically bind source image based on screen width. Here the 2x used for a high pixel density desktop display.
Sample Output for ng-srcset directive in AngularJS:
The output shows that the wikitechy.com logo image was load when the page was load based on the screen width. Here we have used 2x for pixel density which have high pixel density for desktop display.