import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { ErrorCollectComponent } from '@yelon/abc/error-collect';
import { NzFormModule } from 'ng-zorro-antd/form';
import { NzInputModule } from 'ng-zorro-antd/input';
@Component({
selector: 'components-error-collect-basic',
template: `
<form nz-form [formGroup]="validateForm">
<nz-form-item>
<nz-form-control>
<input nz-input formControlName="email" id="email" />
</nz-form-control>
</nz-form-item>
<error-collect />
</form>
`,
standalone: true,
imports: [NzFormModule, ReactiveFormsModule, NzInputModule, ErrorCollectComponent]
})
export class ComponentsErrorCollectBasicComponent implements OnInit {
validateForm = new FormGroup({
email: new FormControl(null, [Validators.required])
});
get email(): FormControl<string | null> {
return this.validateForm.controls.email;
}
ngOnInit(): void {
this.email.markAsDirty();
}
}