这是笨蛋。 http://plnkr.co/edit/UQ4Pb94QzDbScnN7z2Vb?p=preview
根据这个骗子,用户选择了一个 csv 文件。一旦选择文件,其内容就会显示在其下方。这是由于 HTML 代码中提到的 {{fileContent}}。
我希望用户单击保存按钮,而不是直接显示在下面。单击“保存”按钮后,我希望结果显示在控制台日志中,而不是显示在“选择文件”按钮下方。
<html>
</html> //added this code so it allows me to post the question.
知道如何实现这一目标吗?
最佳答案
将fileContent
传递给save()函数
html
<body ng-controller="MainCtrl">
<p>Hello {{name}}!</p>
<input type="file" file-reader="fileContent" />
<button type="button" ng-click="save(fileContent);">Save</button>
<div>{{fileContent}}</div>
</body>
Controller
$scope.save = function(data)
{
console.log(data)
}
关于javascript - 仅当单击“保存”按钮时才导入 csv(添加了 Plunker),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37736520/