1
我需要将此日期传递给api,它需要是一个字符串。我如何做到这一点,因为我使用ng-bootstrap datepicker?当我做了date: this.date.toString()
时,它返回[object] [Object]。我想这是一个字符串格式化日期到要传递到API的字符串
<div class="input-group col-md-3">
<input class="form-control" placeholder="yyyy-mm-dd" name="dp" ngbDatepicker #d="ngbDatepicker" formControlName="date" required>
<button class="input-group-addon" (click)="d.toggle()" type="button">
<i class="fa fa-calendar" aria-hidden="true"></i>
</button>
</div>
TS
this.date = this.myForm.get('date').value
date: this.date.toString(),
实际上,您正在API中发送所有表单日期。或只有日期数据? –
@Ajmalsha。那么这个日期来自于这个表格。我的问题是,我返回[对象] [对象] –
所以你的要求是将表单数据转换为字符串。是吗? –