I would like to get all errors from a form.
I tried to use the live example that came with Angular documentation, and I modified it adding required
to the first field:
createForm() {
this.heroForm = this.fb.group({
name: ['', Validators.required],
secretLairs: this.fb.array([]),
power: '',
sidekick: ''
});
}
https://plnkr.co/edit/6b1paWOlKtXnDn1VVCyP
As you can see, if you empty the name
field it triggers the required
validator and control
related to name field has an errors object... but errors
property of myForm
object is still null
. Why?
Shouldn't it contain an object with all errors that are triggered by validators of the children controls?
So what does errors
property stand for?