javascript - FileReader() is not defined in Angularjs Directive -
i working on file upload functionality on ui. basically, on ui page, need read file contents , display when user selects local file his/her machine. this, googled , found http://plnkr.co/edit/eeqbr65oe8iljm7ueghx?p=preview example. working fine. used in application, not working , giving me error that"filereader" not defined.
here example:
function onreadfile($parse) { return { restrict: 'a', scope: false, link: function(scope, element, attrs) { var fn = $parse(attrs.onreadfile); element.on('change', function(onchangeevent) { var reader = new filereader(); reader.onload = function(onloadevent) { scope.$apply(function() { fn(scope, {$filecontent:onloadevent.target.result}); }); }; reader.readastext((onchangeevent.srcelement || onchangeevent.target).files[0]); }); } }; }
Comments
Post a Comment