Created
October 15, 2013 12:43
-
-
Save dpogorzelski/6991017 to your computer and use it in GitHub Desktop.
Client-side File Encryption: Frontend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This directive handles multiple file selection and makes them available | |
// as an array to the onFile() function inside the controller | |
directives.directive('fileselect', ['$parse', | |
function($parse) { | |
return function(scope, elem, attr) { | |
var fn = $parse(attr['fileselect']); | |
elem.bind('change', function(evt) { | |
var files = []; | |
var fileList = evt.target.files; | |
for (var i = 0; i < fileList.length; i++) { | |
files.push(fileList[i]); | |
} | |
scope.$apply(function() { | |
fn(scope, { | |
files: files, | |
$event: evt | |
}); | |
}); | |
}); | |
}; | |
} | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment