0
我正在使用角度2 mydatepicker。angular2 mydatepicker無法正常工作
我需要默認選定值。
這裏是我的代碼
import {IMyOptions,IMyDateModel} from 'mydatepicker';
import { FormGroup, FormBuilder, Validators ,FormControl} from '@angular/forms';
export class CommentsPage {
Addevent;
private myDatePickerOptions: IMyOptions = {
dateFormat: 'yyyy-mm-dd',
};
constructor() {
let date = new Date();
this.Addevent.controls['EVENT_DATE'].setValue({
date: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate()}
});
}
ngOnInit()
{
this.Addevent = this.formbuilder.group({
EVENT_DATE:[''],
});
}
}
這裏是我的HTML代碼
<form [formGroup]="Addevent" (ngSubmit)="add(Addevent.value)" novalidate>
<div>
<h5 class="d1">DATE</h5>
<my-date-picker name="mydate" [options]="myDatePickerOptions"
formControlName="EVENT_DATE"></my-date-picker>
</div>
</form>
但我得到這個犯錯
Error: There is no FormControl instance attached to form control element with name: 'EVENT_DATE'
我怎樣才能解決這個問題。
請告訴我,
謝謝。
感謝UR reply.still我是得到同樣的犯錯.. – ANISUNDAR