Javascript 读取angularjs中表单输入的文件内容

Javascript 读取angularjs中表单输入的文件内容,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,我的硬盘中有一个JSON文件,当我用输入字段选择该文件时,如何读取该文件的内容 我必须阅读的内容,并发送一些API的数据内容 我需要这样的东西: <input type="file" id="dashboardExportedFile"> <button type="button" ng-click="importDashboard">Import</button> <script> $scope.importDashboard = funct

我的硬盘中有一个JSON文件,当我用输入字段选择该文件时,如何读取该文件的内容

我必须阅读的内容,并发送一些API的数据内容

我需要这样的东西:

<input type="file" id="dashboardExportedFile">
<button type="button" ng-click="importDashboard">Import</button>
<script>
  $scope.importDashboard = function (
    var content = $("#dashboardExportedFile").content
    console.log(content);
  };
</script>

进口
$scope.importDashboard=函数(
var content=$(“#仪表板导出文件”).content
控制台日志(内容);
};

我认为您需要一个文件阅读器。请按照我的链接查看.txt文件的工作示例。希望您可以使用它: [JSFiddle][1]

[1]: http://jsfiddle.net/alexsuch/6aG4x/

看看这个Stackoverflow问题,它可能会为您提供您想要的答案: