我使用提交的表單發送帶有角度的POST請求。 我有optionals輸入字段,當我鍵入的東西那裏刪除它,然後在我的請求我有這個字段包含「」。 這是怎麼回事?用角度發送請求 - 請求中的空元素
那我怎麼看形式:
<label class="col-md-2 col-xs-2 my-label" for="contactFirstName">Imię</label>
<div class="col-md-3 col-xs-3">
<input type="text" class="form-control" id="contactFirstName" name="contactFirstName"
placeholder="Imię"
ng-model="loan.newLoan.contactPerson.firstName" >
</div>
而這就是我如何發送請求:
function create() {
return RequestFactory.save({id1:'loans', id2:'create'},vm.newLoan,
function() {
MessageFactory.setSuccess({show:true, msg:'success'});
$state.reload('loan.new');
}, function(response){
vm.isError = true;
ErrorFactory.errorHandler(vm.errorMessages, response);
});
}
和發送的時候,我與這個領域要求JSON看起來是這樣的:
{"firstName":""}
那好嗎?或者請求中沒有該字段,如果它是空的? 我該怎麼做?
您好!請接受我的答案,如果它解決了你的問題。 :) [如何接受答案工作?](http://meta.stackexchange.com/a/5235/170863) –
是的,它解決了它,謝謝。 – luk1