File pick with Angular JSの質問を参照して、ファイル リーダーのロード時に、親スコープのプロパティを変更したいと考えています。検討
$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);
});
});
HTMLでこれを達成するにはどうすればよいですか:
<input ng-model="photo"
onchange="angular.element(this).scope().file_changed(this)"
type="file" accept="image/*" />
毎回失敗し、未定義のプロパティ 'fileLoaded' を設定できません。