Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body ng-app="sample">
  <div><input type="file" media-upload="photo_a" /></div>
  <div><input type="file" media-upload="photo_b" /></div>
  
  <ul class="photo-list">
    <li class="photopane">
      <img class="photo" ng-src="{{photo_a}}" ng-show="photo_a" />
    </li>
    <li class="photopane">
      <img class="photo" ng-src="{{photo_b}}" ng-show="photo_b" />
    </li>
  </ul>
</body>
</html>
 
angular.module('media', [])
.directive('mediaUpload', function ($parse) {
    return {
        restrict : 'AC',
        link : function (scope, element, attrs) {
            var setter = $parse(attrs.mediaUpload);
            var reader = new FileReader();
            
            reader.onload = function (e) {
                scope.$apply(function () {
                    setter.assign(scope, reader.result);
                });
            };
            
            element.bind('change', function (e) {
                reader.readAsDataURL(this.files[0]);
            });
        }
    };
});
angular.module('sample', ['media']);
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
study1kpro
0viewers