我使用angular-file-upload。我有活动$('.sudoku input').change(function() {
var editedCell = $(this).closest('.td')[0];
// get the row and col where the edit happened
var row = $(this).closest('.tr').data('row'),
col = $(this).closest('.td').data('column'),
val = $(this).val();
var hasDups = false;
// check if any other cells in the same row has same value
// note: can be made simpler with $(this).siblings().each(...)
$('.sudoku .tr[data-row='+row+']').each(function() {
if($(this).find('input').val() === val && this !== editedCell) {
$(this).addClass('duplicate');
hasDups = true;
}
});
// check if any other cells in the same col has same value
$('.sudoku .td[data-col='+col+']').each(function() {
if($(this).find('input').val() === val && this !== editedCell) {
$(this).addClass('duplicate');
hasDups = true;
}
});
if(hasDups) $(this).addClass('duplicate');
});
。
Angular JS:
ng-click="removeFile(item)"
对象$scope.removeFile = function (item){
console.log(item);
}
中有index
个参数,对我来说它是空的。如何在删除之前获取当前文件的索引?
答案 0 :(得分:2)
如图in the in the demo所示,他们在图片列表中使用ng-click="item.remove()"
,然后在getIndexOfItem
function is used internally中使用文件列表中的索引。但是在你的包装removeFile
中,你可以像这样:
$scope.removeFile = function (item){
item.remove();
//index of the file in the list is - item.$index
}