Lint错误消息:
src/app/detail/edit/edit.component.ts[111,5]: for (… in …)
statements must be filtered with an if statement
代码段(这是一个工作代码.它也可以在angular.io form validation section获得):
for (const field in this.formErrors) { // clear prevIoUs error message (if any) this.formErrors[field] = ''; const control = form.get(field); if (control && control.dirty && !control.valid) { const messages = this.validationMessages[field]; for (const key in control.errors) { this.formErrors[field] += messages[key] + ' '; } } }