我正在尝试使用输入[type = file]显示用户选择的文件列表.
HTML
<div ng-app="myApp">
<div ng-controller="UploadFilesCtrl">
<input type="file" onchange="angular.element(this).scope().uploadFiles(this)" multiple />
<ul>
<li ng-repeat="name in filenames">
{{name}}
</li>
</ul>
<button ng-click="test()">PRINT</button>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
JS
app = angular.module('myApp');
app.controller('UploadFilesCtrl', ['$scope', function($scope){
$scope.uploadFiles = function(element){
var files = element.files;
var filenames=[];
for (i=0; i<files.length; i++){
filenames.push(files[i].name);
}
$scope.files = files;
$scope.filenames = filenames;
console.log(files, filenames);
};
$scope.test = function(){
console.log($scope.files, $scope.filenames);
}
}]);
Run Code Online (Sandbox Code Playgroud)
由于某种原因,列表永远不会更新.
在filenames与files变量中$scope从来没有得到过的之外更新uploadFiles功能(当我点击选择文件后,打印按钮,我得到未定义).
有任何想法吗?
谢谢!
有没有办法将图像分割成区域(现在它是JLabel但我可以在必要时更改它)?
我在我的程序中使用swing并且我有一个图像(这个例子是正方形),里面有一些三角形,星形和梯形(它可以是JPG,PNG等).
想法是用户将在其中一个形状中单击,然后我将在用户单击的区域顶部放置另一个小图标.用户可以点击多个区域,但在一天结束时,我需要知道点击了哪些形状.
似乎有可能有人吗?