我是今天使用角度js的新手我试图上传文件并删除这个上传的文件,但现在我遇到了删除文件问题
这是我的html
代码:
<div>
<ul>
<li ng-repeat="files in table.process_data.attachments">
<a target="_self" class="col-sm-6" href="sales/download/{{files.filepath}}/{{files.name}}">{{files.name}}</a>
<input type="button" class="btn btn-xs btn-danger col-sm-offset-3" ng-click="table.deleteFile(files.id)" value="delete"/>
</li>
</ul>
这是我的angularjs
删除功能:
vm.deleteFile = function (id) {
$scope.getJson('sales/removeAttachment', id, function (r) {
if (r.error == null) {
vm.editSales(vm.edit_id);
vm.showToastSuccess('file deleted');
} else {
vm.showToastFail(r.error);
}
});
};
答案 0 :(得分:1)
我认为这会帮助你!
vm.deleteFile = function (id) {
$scope.getJson('file_upload/removeAttachment', id, function (r) {
if (r.success) {
vm.editSales(vm.edit_id);
vm.showToastSuccess('file deleted');
} else if (r.error) {
vm.showToastFail(r.error);
} else {
vm.showToastFail('something went wrong during delete!');
}
});
};