When i first load the page, the form appears like this
But after i successfully create an announcement, i reset the page with this.announcementCreateForm.reset()
code and it resets the below way
I call the below method buildAnnouncementForm()
during ngOnInit()
private buildAnnouncementForm() {
this.announcementCreateForm = this.fb.group({
announcementTitle: ['', [Validators.required]],
announcementText: '',
announcementFor: ['', [Validators.required]],
announcementType: ['', [Validators.required]],
announcementFromDate: [this.announcementFromDate, Validators.required],
announcementToDate: [this.announcementToDate, Validators.required]
});
}
I call the reset
method after success
resetAnnouncementPage() {
if (this.announcementCreateForm.valid) {
console.log("Reset...");
this.announcementCreateForm.reset();
this.announcementCreateForm.markAsPristine();
//this.announcementCreateForm.markAsUntouched();
}
}
My reset, wants me to bring the form like it looks during loading.. how to do it ?