var app = angular.module('app', []);
app.controller('MainCtrl', function ($scope, fileReader) {
	$scope.images=[];
	
	$scope.getFile = function () {
        fileReader.readAsDataUrl($scope.files, $scope).then(function(imageDataURLs) {
			for(var i = 0; i < imageDataURLs.length ; i ++){
				var image ={
					"url":imageDataURLs[i]
				};
				$scope.images.push(image);
			}    
			
		});
    };
});
app.factory("fileReader",["$q", "$log",function ($q, $log) {
	var onLoad = function(reader, deferred, scope) {
		return function () {
			scope.$apply(function () {
				deferred.resolve(reader.result);
			});
		};
	};

	var onError = function (reader, deferred, scope) {
		return function () {
			scope.$apply(function () {
				deferred.reject(reader.result);
			});
		};
	};

	var onProgress = function(reader, scope) {
		return function (event) {
			scope.$broadcast("fileProgress",
				{
					total: event.total,
					loaded: event.loaded
				});
		};
	};

	var getReader = function(deferred, scope) {
		var reader = new FileReader();
		reader.onload = onLoad(reader, deferred, scope);
		reader.onerror = onError(reader, deferred, scope);
		reader.onprogress = onProgress(reader, scope);
		return reader;
	};

	var readOneFileAsDataURL= function (file, scope) {
		var deferred = $q.defer();
		var reader = getReader(deferred, scope);         
		reader.readAsDataURL(file);
		return deferred.promise;
	};
	var readManyFileAsDataURL = function(files, scope){
		var promises=[];
		for(var i = 0 ; i < files.length; i ++){
			promises.push(readOneFileAsDataURL(files[i], scope));
		}
		return $q.all(promises);
	};
	return {
		readAsDataUrl: readManyFileAsDataURL  
	};
}]);
app.directive("ngFileSelect",function(){    
  return {
    link: function($scope,el){          
      el.bind("change", function(e){          
        $scope.files = (e.srcElement || e.target).files;
        $scope.getFile();
      });          
    }        
  }
});
@@ -149,16 +149,19 @@
 %0A       
+ //
  fileRea
@@ -168,25 +168,33 @@
 der.read
+ManyFile
 AsDataU
-rl
+RL
 ($scope.
@@ -242,16 +242,19 @@
 s) %7B%0A%09%09%09
+// 
 for(var 
@@ -298,16 +298,19 @@
 +)%7B%0A%09%09%09%09
+// 
 var imag
@@ -319,16 +319,19 @@
 =%7B%0A%09%09%09%09%09
+// 
 %22url%22:im
@@ -353,15 +353,21 @@
 %09%09%09%09
+// 
 %7D;%0A%09%09%09%09
+// 
 $sco
@@ -392,16 +392,19 @@
 ge);%0A%09%09%09
+// 
 %7D    %0A%09%09
@@ -407,19 +407,274 @@
  %0A%09%09%09%0A%09%09
-%7D);
+// %7D);%0A%09%09for(var i = 0 ; i %3C $scope.files.length; i ++)%7B%0A%09%09%09var file = $scope.files%5Bi%5D;%0A%09%09%09fileReader.readOneFileAsDataURL(file, $scope).then(function(imageDataURL) %7B%0A%09%09%09%09var image =%7B%0A%09%09%09%09%09%22url%22:imageDataURL%0A%09%09%09%09%7D;%0A%09%09%09%09$scope.images.push(image);%09%09%0A%09%09%09%7D);%0A%09%09%7D
 %0A    %7D;%0A
@@ -1910,17 +1910,25 @@
 read
+ManyFile
 AsDataU
-rl
+RL
 : re
@@ -1946,18 +1946,63 @@
 sDataURL
-  
+,%0A%09%09readOneFileAsDataURL : readOneFileAsDataURL
 %0A%09%7D;%0A%7D%5D)

complete read each file a the time