在this示例中,第一个文件上传裁剪工作正常,但第二个文件上传无效。
var app = angular.module('app', ['ngImgCrop']);
app.controller('Ctrl', function($scope) {
$scope.myImage='';
$scope.myCroppedImage='';
var handleFileSelect=function(evt) {
var file=evt.currentTarget.files[0];
var reader = new FileReader();
reader.onload = function (evt) {
$scope.$apply(function($scope){
$scope.myImage=evt.target.result;
});
};
reader.readAsDataURL(file);
};
angular.element(document.querySelector('#fileInput'))
.on('change',handleFileSelect);
});
var app1 = angular.module('app1', ['ngImgCrop']);
app1.controller('Ctrl1', function($scope) {
$scope.myImage1='';
$scope.myCroppedImage1='';
var handleFileSelect1=function(evt) {
var file1=evt.currentTarget.files[0];
var reader1 = new FileReader();
reader1.onload = function (evt) {
$scope.$apply(function($scope){
$scope.myImage1=evt.target.result;
});
};
reader1.readAsDataURL(file1);
};
angular.element(document.querySelector('#fileInput1'))
.on('change',handleFileSelect1);
});