如何在angularjs中将变量的值设置为上传文件的json数据? [英] How to set a variable's value to uploaded file json data in angularjs?
本文介绍了如何在angularjs中将变量的值设置为上传文件的json数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是angularJS的新手.我想使用上传JSON文件< input type ="file" onchange ="angular.element(this).scope().uploadFile(this.files)"/>
I'm new to angularJS. I want to upload a JSON file using
<input type="file"onchange="angular.element(this).scope().uploadFile(this.files)"/>
我正在尝试像这样在控制器中访问其数据:
and I am trying to access its data in the controller like this:
$scope.uploadFile = function(files) {
$scope.jsonData = files[0].data;
};
但是我的变量中有未定义的内容.我必须使用此变量来填充网站上的其他各个字段.请帮助我如何访问上传的输入文件的数据.
But I get an undefined in my variable. I have to use this variable to populate various other fields on the website. Kindly help me how to access the data of the input file uploaded.
推荐答案
查看全文