diff options
Diffstat (limited to 'js/directive/NewsReadFile.js')
-rw-r--r-- | js/directive/NewsReadFile.js | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/js/directive/NewsReadFile.js b/js/directive/NewsReadFile.js index d3ed5b80e..89ed0adfc 100644 --- a/js/directive/NewsReadFile.js +++ b/js/directive/NewsReadFile.js @@ -10,19 +10,22 @@ app.directive('newsReadFile', () => { 'use strict'; - return (scope, elm, attr) => { + return (scope, elem, attr) => { - let file = elm[0].files[0]; - let reader = new FileReader(); + elem.change(() => { - reader.onload = (event) => { - elm[0].value = 0; - scope.$fileContent = event.target.result; - scope.$apply(attr.newsReadFile); // FIXME: is there a more flexible - // solution where we dont have to - // bind the file to scope? - }; + let file = elem[0].files[0]; + let reader = new FileReader(); - reader.reasAsText(file); + reader.onload = (event) => { + elem[0].value = 0; + // FIXME: is there a more flexible solution where we dont have + // to bind the file to scope? + scope.$fileContent = event.target.result; + scope.$apply(attr.newsReadFile); + }; + + reader.readAsText(file); + }); }; });
\ No newline at end of file |