AngularJS ngSrcset directive Example

<html ng-app="myApp">
<head>
<script src="http://www.tutorialsavvy.com//ajax.go...
<meta charset="utf-8">
<title>AngularJS ngSrcset Example</title>
</head>
<body ng-controller="MyController">
<h3>ngSrcset directive Example</h3>
<img ng-srcset="{{myImageSize100}},{{myImageSize100}},{{myImageSize200}}"></img>
<script>
var myApp = angular.module("myApp", []);
myApp.controller("MyController", ["$scope", function($scope) {
$scope.myImageSize50 = "http://www.gravatar.com/avatar/c6e6c5... 100w";
$scope.myImageSize100 = "http://www.gravatar.com/avatar/c6e6c5... 300w";
$scope.myImageSize200 = "http://www.gravatar.com/avatar/c6e6c5... 700w";
}]);
</script>
</body>
</html>
The output of the above code is embedded in below JSBIN link.Just resize the window to check how ngSrcset changes the image URL and display different Gravatar image size.AngularJS ngSrcset Example
Published on November 20, 2014 09:18
No comments have been added yet.