3 * http://stackoverflow.com/questions/17063000/ng-model-for-input-type-file
5 * After reading, the contents will be available in the scope variable
6 * referred to by container="..."
9 angular.module('egCoreMod')
10 .directive("egFileReader", [function () {
15 link: function (scope, element, attributes) {
16 // TODO: support DataURL, etc. via attrs
17 element.bind("change", function (changeEvent) {
18 var reader = new FileReader();
19 reader.onload = function (loadEvent) {
20 scope.$apply(function () {
21 scope.container = loadEvent.target.result;
24 reader.readAsText(changeEvent.target.files[0]);