3
從昨天值我與與角料2日期選擇器一個問題所困擾, 前的最後npm install
它正常工作,現在我得到:錯誤:日期選擇:不被識別爲一個日期對象由DateAdapter
ERROR Error: Datepicker: value not recognized as a date object by DateAdapter.
HolidayRequestComponent.html:21
21日線是我的<input
開始
<md-input-container [formGroup]="dateRangeForm">
<input
mdInput
name="date_from"
[mdDatepicker]="from"
placeholder="Start date"
formControlName="holidayDataControl"
[ngModel]="date_from"
>
<md-datepicker-toggle mdSuffix [for]="from"></md-datepicker-toggle>
</md-input-container>
<md-datepicker #from></md-datepicker>
我component.ts:
import {Component, OnInit, Inject } from '@angular/core';
import {MD_DIALOG_DATA, MdDialog } from '@angular/material';
import {FormBuilder, FormControl, FormGroup, NgForm, Validators} from '@angular/forms';
import {Observable} from 'rxjs/Observable';
@Component({
selector: 'app-holiday-request',
templateUrl: './holiday-request.component.html',
styleUrls: ['./holiday-request.component.css']
})
export class HolidayRequestComponent implements OnInit {
public date_from = new Date();
constructor(@Inject(MD_DIALOG_DATA) public data: any,
private fb: FormBuilder,
) {
this.dateRangeForm = new FormGroup({
holidayDataControl: new FormControl('', Validators.required)
});
}
}
感謝您節省我的時間! –