summaryrefslogtreecommitdiffstats
path: root/js/directive/NewsReadFile.js
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-23 01:11:53 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-23 01:11:53 +0200
commit8f833877eebd93f1c938833dd28255c63037588f (patch)
treefc304acb29c2327ead6648bf308243bdfb6ee468 /js/directive/NewsReadFile.js
parenta0b6fad1ada52457c2c5022fcb7685c1fff16abb (diff)
fix slideup
Diffstat (limited to 'js/directive/NewsReadFile.js')
-rw-r--r--js/directive/NewsReadFile.js25
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