使用 angularjs 清除输入字段
Clear input field using angularjs
让我改一下我的问题,我有一个问题,删除上传的文件,所以我已经按照建议对我的代码进行了一些修改,但它仍然不起作用,而且还有一个覆盖我上传的问题文件,所以每次我上传东西它都会覆盖以前的文件,我希望能够上传很多然后删除它们,谢谢
<form class="htmlForm">
<label for="id_payment_proof">{% trans "Payment proof:" %}</label>
<div class="full-size">
<div class="input-control full-size file" data-role="input">
<input id="id_payment_proof" type="file" file-model="payment_proof"/>
<button class="button"><span class="mif-folder"></span></button>
</div>
</div>
<div ng-if="client_invoice.payment_proof_filename">
<a ng-href="{{ client_invoice.payment_proof }}"
ng-bind="client_invoice.payment_proof_filename"
target="_blank"></a>
<button class="button" ng_click="clearInvoice()">
<span class="mif-bin"></span>
</button>
</div>
{% endverbatim %}
</form>
控制器:
editInvoiceHandler = (event, row) ->
$scope.payment_proof = undefined
$scope.htmlFormEl.reset()
$scope.row = row
$scope.client_invoice = row.data()
hasChanges = false
$scope.editMode = true
$scope.$digest()
$scope.clearInvoice() = () ->
$scope.payment_proof = 0
在你的控制器中:
$scope.deleteUploadedFile = function () {
$scope.payment_proof = null
}
试试这个
<button class="button" ng-click="payment_proof = ''"> Delete</button>
我没有测试下面的代码,但认为它可能与您需要的类似:
$scope.payment_proof = []; // presume you don't want any pre-loaded entries
$scope.add(new_entry) = payment_proof.push(new_entry);
$scope.delete(index) = payment_proof.splice(index,1);
$scope.clearInvoice = { $scope.payment_proof = []; }
//Then submit the payment_proof to the back end
想法是操作一个数组(payment_proof
在你的情况下)并将其提交到后端。
让我改一下我的问题,我有一个问题,删除上传的文件,所以我已经按照建议对我的代码进行了一些修改,但它仍然不起作用,而且还有一个覆盖我上传的问题文件,所以每次我上传东西它都会覆盖以前的文件,我希望能够上传很多然后删除它们,谢谢
<form class="htmlForm">
<label for="id_payment_proof">{% trans "Payment proof:" %}</label>
<div class="full-size">
<div class="input-control full-size file" data-role="input">
<input id="id_payment_proof" type="file" file-model="payment_proof"/>
<button class="button"><span class="mif-folder"></span></button>
</div>
</div>
<div ng-if="client_invoice.payment_proof_filename">
<a ng-href="{{ client_invoice.payment_proof }}"
ng-bind="client_invoice.payment_proof_filename"
target="_blank"></a>
<button class="button" ng_click="clearInvoice()">
<span class="mif-bin"></span>
</button>
</div>
{% endverbatim %}
</form>
控制器:
editInvoiceHandler = (event, row) ->
$scope.payment_proof = undefined
$scope.htmlFormEl.reset()
$scope.row = row
$scope.client_invoice = row.data()
hasChanges = false
$scope.editMode = true
$scope.$digest()
$scope.clearInvoice() = () ->
$scope.payment_proof = 0
在你的控制器中:
$scope.deleteUploadedFile = function () {
$scope.payment_proof = null
}
试试这个
<button class="button" ng-click="payment_proof = ''"> Delete</button>
我没有测试下面的代码,但认为它可能与您需要的类似:
$scope.payment_proof = []; // presume you don't want any pre-loaded entries
$scope.add(new_entry) = payment_proof.push(new_entry);
$scope.delete(index) = payment_proof.splice(index,1);
$scope.clearInvoice = { $scope.payment_proof = []; }
//Then submit the payment_proof to the back end
想法是操作一个数组(payment_proof
在你的情况下)并将其提交到后端。