With reference to question File pick with Angular JS, on file reader's on load i want to modify a parent scope's property. Consider
$scope.fileLoaded = false; //initially
$scope.file_changed = function(element, $scope) {
$scope.$apply(function(scope) {
var photofile = element.files[0];
var reader = new FileReader();
reader.onload = function(e) {
$scope.fileLoaded = true; // I intend to do!
...
};
reader.readAsDataURL(photofile);
});
});
How do i achieve this for HTML:
<input ng-model="photo"
onchange="angular.element(this).scope().file_changed(this)"
type="file" accept="image/*" />
It fails every time with error Cannot set property 'fileLoaded' of undefined.