I am looking to retrieve the values of a FileList object after selecting files using an HTML input FileUpload element. Although I can see the FileList object in the console window when I console.log
it, I am facing challenges accessing the values using AngularJS.
Below is the code snippet in question:
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="MyCtrl">
<input type="file" id="myFile" multiple size="50" ng-model="file" onchange="angular.element(this).scope().myFunction()">
<p id="demo" ng-repeat="file in fileList">
Name: {{file.name}} </br>
Type: {{file.type}} </br>
</p>
{{fileList}}
</div>
<script>
var app = angular.module('myApp', []);
app.controller('MyCtrl', ['$scope', function($scope){
$scope.myFunction = function(){
var x = document.getElementById("myFile");
$scope.fileList = x.files;
console.log($scope.fileList);
};
}]);
</script>
</body>
</html>