Answer the question
In order to leave comments, you need to log in
Why is Angular form not validating?
Hello, I created a form, it has a DatePicker, I use https://materializecss.com/pickers.html, the form works successfully, opens and selects the date and also inserts it into the input, but the problem is that Angular does not see the changes and thinks Input is still empty and asks for a date. But if you use the standard DatePicker from input type="date", then everything works.
<div class="input-field">
<input
type="text"
id="preparationStartDate"
formControlName="preparationStartDate"
#preparationStartDate
[ngClass]="{'invalid': form.get('preparationStartDate').invalid && form.get('preparationStartDate').touched}"
>
<label for="preparationStartDate">Начало</label>
</div>
ngOnInit() {
this.form = new FormGroup({
preparationStartDate: new FormControl('', Validators.required)
})
}
ngAfterViewInit() {
this.preparationStartDate = MaterialService.initDatePicker(this.startRef, null)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question