Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <input type="file" onchange="angular.element(this).scope().onFileChange(this)">
- $scope.onFileChange = function (fileEl) {
- var files = fileEl.files;
- var file = files[0];
- var reader = new FileReader();
- reader.onloadend = function(evt) {
- if (evt.target.readyState === FileReader.DONE) {
- $scope.$apply(function () {
- $scope.something = JSON.parse(evt.target.result);
- });
- }
- };
- reader.readAsText(file);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement