這是我的簡單代碼,只適用於'標題'。 'docdatetime'控件顯示爲空白。我究竟做錯了什麼?如何綁定日期/時間窗體控件?
//template ===================================================
<div class="form-group">
<input type="text" id="title" formControlName="title" class="form-control">
</div>
<div class="form-group">
<input type="datetime-local" id="docdatetime" formControlName="docdatetime" class="form-control">
</div>
//component.ts ===============================================
import { FormGroup, FormControl } from '@angular/forms';
.....
export class.....
docForm: FormGroup;
ngOnInit() {
let docTitle = 'My first document';
let docDate = 'Jun 15, 2015, 9:43:11 PM';
this.docForm = new FormGroup({
'title': new FormControl(docTitle),
'docdatetime': new FormControl(new Date(docDate))
});
}
也不起作用:-( – VladP
它工作正常在這[plunk](https://plnkr.co/edit/40M4ZtgIteJJkVkO8mN6?p=preview)。你可能錯過了其他的東西。你能顯示你的代碼的其餘部分嗎? –
謝謝君康。 ..我只需重新啓動Visual Studio代碼並清理瀏覽器的緩存。 – VladP