Javascript Sweet警报后的文件上载窗口
用例:Javascript Sweet警报后的文件上载窗口,javascript,html,angularjs,sweetalert,Javascript,Html,Angularjs,Sweetalert,用例: 我正在尝试将窗口.警报更改为甜蜜警报 当我使用window.alert时,文件上传窗口前会出现一个警报弹出窗口,然后单击“确定”,文件上传窗口就会出现 但是,将window.alert更改为Sweet alert后,文件上载窗口同时出现。 当用户单击标签时,会显示Sweet alert,然后用户可以选择该文件 uploadAlert(): $scope.uploadAlert = function() { $window.alert(~~~~~~); } 如何
- 我正在尝试将
更改为甜蜜警报窗口.警报
- 当我使用window.alert时,文件上传窗口前会出现一个警报弹出窗口,然后单击“确定”,文件上传窗口就会出现
- 但是,将
更改为Sweet alert后,文件上载窗口同时出现。window.alert
uploadAlert():
$scope.uploadAlert = function() {
$window.alert(~~~~~~);
}
如何解决这个问题
<label for="ScanFile"><i class="fa fa-upload" style='cursor: pointer;' ng-click="uploadAlert(event, row)"></i></label>
<input id="ScanFile" type="file"/>
现在,您可以使用id以编程方式单击
,在关闭sweetalert对话框后打开对话框
document.getElementById("ScanFile").click();
例如:
$scope.uploadAlert = function(e) {
e.preventDefault(); // this will prevent the upload dialog from opening
swal({
title: 'Demo',
text: 'Demo',
showCancelButton: true,
confirmButtonText: 'Submit',
},
function() {
document.getElementById("ScanFile").click();
});
});
}
是否在UI中显示给用户?是的,这是用户的视图我的意思是显示给用户的标签或Choosefile按钮,或者两者都可见?仅显示标签。我用CSSThanks隐藏文件输入!但是我应该在ng单击中使用$event
而不是event
$scope.uploadAlert = function(e) {
e.preventDefault(); // this will prevent the upload dialog from opening
swal({
title: 'Demo',
text: 'Demo',
showCancelButton: true,
confirmButtonText: 'Submit',
},
function() {
document.getElementById("ScanFile").click();
});
});
}